7913 Posts in 1355 Topics by 930 members
DataObjectManager Module
SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager Display Question
Discuss the DataObjectManager module, and the related ImageGallery module.
Moderators: martimiz, UncleCheese, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
| Go to End | Next > | |
| Author | Topic: | 1295 Views |
-
ImageDataObjectManager Display Question

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.
-
Re: ImageDataObjectManager Display Question

8 October 2010 at 2:52am
How about..
href="$Photo.SetWidth(800).URL"
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com -
Re: ImageDataObjectManager Display Question

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.
-
Re: ImageDataObjectManager Display Question

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 -
Re: ImageDataObjectManager Display Question

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!
-
Re: ImageDataObjectManager Display Question

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?
-
Re: ImageDataObjectManager Display Question

8 October 2010 at 7:00am
Might want to try removePermission('upload');
--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com -
Re: ImageDataObjectManager Display Question

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.
| 1295 Views | ||
| Go to Top | Next > |

