Jump to:

7939 Posts in 1472 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Adding an Image to FileDataObjectManager

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 941 Views
  • Garrett
    Avatar
    Community Member
    245 Posts

    Adding an Image to FileDataObjectManager Link to this post

    Hi,

    Is there some reason that I cannot add an Image file to a FileDataObjectManager? What if I have an object that requires BOTH a file AND an image?

    I have my $has_one for the image, but when I click on "Attach Image," nothing happens and the ImageID is not added to the database. Why not?

    Thanks,
    Garrett

  • UncleCheese
    Avatar
    4085 Posts

    Re: Adding an Image to FileDataObjectManager Link to this post

    No reason you can't do that. Post your code?

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: Adding an Image to FileDataObjectManager Link to this post

    Hey there Uncle Cheese. Thanks for your reply. There was a mistake in my code While I have you here, though, I have another question for you-- how do you adjust the SIZE of images displayed inside the DataObjectManager inside the CMS? As you know, this can get very cantankerous!

    Thanks,
    Garrett

  • UncleCheese
    Avatar
    4085 Posts

    Re: Adding an Image to FileDataObjectManager Link to this post

    I'm not sure what you mean. In the popup? Grid view? If you use ImageDOM, you get a slider that allows you to change the size of the images.

  • Garrett
    Avatar
    Community Member
    245 Posts

    Re: Adding an Image to FileDataObjectManager Link to this post

    I mean the images displaying IN the actual DataObjectManager table IN the CMS. In List View. I don't know how to control the size of these images here. They show up ACTUAL size instead of trying to fit themselves into the table.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Adding an Image to FileDataObjectManager Link to this post

    Oh, wow. That's unusual that you're displaying the images in list view. Usually you use a custom getter for that.

    In your headings array, you have something like:

    array(
    'Name' => 'Name of Thing',
    'Description' => 'Description',
    'DOMThumbnail' => 'Thumbnail of thing'
    );

    and in your dataobject:

    function getDOMThumbnail()
    {
    return $this->MyImageField()->CroppedImage(50,50);
    }

    The headings array always looks for getXXX first, then falls back on the property itself.

    941 Views
Page: 1
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.