Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

Moderators: martimiz, UncleCheese, Sean, Ed, biapar, Willr, Ingo, swaiba

ImageDataObjectManager Display Question


Go to End


11 Posts   2434 Views

Avatar
Liam

Community Member, 470 Posts

7 October 2010 at 5:37pm

I've successfully setup imagedataobjectmanager to manage my images on a dataobject for use in a basic lightbox setup. I've added in the title field to give each image a title. The following code works perfectly with how I've setup my database:


<% control Photos %>
     <a href="$Photo.URL" <% if Title %> title="$Title" <% end_if %>">$Photo.CroppedImage(110,110)</a>			
<% end_control %>

I don't think you need the other code, as it works fine.

My question is, right now it links to the full size image that is uploaded via $Photo.URL. I'd like to link to a resized image in case the original image the client uploads in the CMS is too large.

Is the best case to subclass the image class or am I missing something obvious? I tried nesting the Photo control within the href, but that produced errors.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 October 2010 at 2:52am

How about..

href="$Photo.SetWidth(800).URL"

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

Community Member, 470 Posts

8 October 2010 at 4:03am

I tried that as well, but it returns the full <img> tag to the resized image in its place. It seems to be ignoring the .URL call.

I tried using .Link as well just to test, but still nothing.

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 October 2010 at 4:19am

Might be one too many levels of dot syntax..

<% control Photo %><% control SetWidth(800) %>$URL<% end_control %><% end_control %>

That's the ridiculously verbose, but surefire way to do it. :)

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

Community Member, 470 Posts

8 October 2010 at 4:27am

Perfect. That works.

Funny I tried something along those lines last night, but it produced an error. It was also after midnight, so I probably wasn't thinking clearly and missed something obvious.

Cheers buddy!

Avatar
Liam

Community Member, 470 Posts

8 October 2010 at 5:57am

Okay, one last quick question.

I'm trying to limit the total number of uploads by using the below in my getcmsfields function on page.


		if ($this->Photos()->Count() > 4){
			$manager->removePermission('add');
		}

This works, except the add button still display. Just clicking on it, brings up a blank lightbox with no option to upload anything.

Shouldn't this be removing the the add button all together?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

8 October 2010 at 7:00am

Might want to try removePermission('upload');

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
Liam

Community Member, 470 Posts

8 October 2010 at 8:24am

That removes it, but now I'm left with this html in its place:

<div class="dataobjectmanager-actions ">
<h3>Photoss</h3>
</div>

I'm assuming this is the plural listing of the source.

Go to Top