Jump to:

7935 Posts in 1536 Topics by 943 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » ImageDataObjectManager Display Question

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 1565 Views
  • Liam
    Avatar
    Community Member
    470 Posts

    ImageDataObjectManager Display Question Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    How about..

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

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

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    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

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    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!

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    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?

  • UncleCheese
    Avatar
    4085 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    Might want to try removePermission('upload');

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

  • Liam
    Avatar
    Community Member
    470 Posts

    Re: ImageDataObjectManager Display Question Link to this post

    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.

    1565 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.