Jump to:

5542 Posts in 1739 Topics by 1225 members

Customising the CMS

SilverStripe Forums » Customising the CMS » Files not available for extended Image object (SS3)

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

Page: 1
Go to End
Author Topic: 401 Views
  • JimmyNZ
    Avatar
    Community Member
    2 Posts

    Files not available for extended Image object (SS3) Link to this post

    In SS3, I have a CustomImage object extending Image to make use of some custom Image GD functions.
    However the upload field for this does not show existing files in the Assets folder. Replacing CustomImage with Image, these files then show again. Any ideas?

    public static $has_one = array(
    'Thumbnail' => 'CustomImage',
    );

    ...

    $ThumbUpload = new UploadField('Thumbnail', 'Thumbnail image');
    $ThumbUpload->setFolderName('Uploads/images/');
    $fields->addFieldToTab('Root.Main', $ThumbUpload, 'Content');

  • martimiz
    Avatar
    Forum Moderator
    1086 Posts

    Re: Files not available for extended Image object (SS3) Link to this post

    Hi JimmyNZ

    Sorry for the late reply, You are correct: the UploadField will only show files that are part of your CustomImage class. That's because what you see in your UploadForm file list, are not purely images as such, they are dataObjects of a given class, that have an Image attached to them. And you cannot really mix them up...

    So the advice is to use a DataExtension for the Image class instead. That way all your 'images' will still be Image DataObjects, but can have extra data attached to them.

    See the UploadForm documentation: http://doc.silverstripe.org/framework/en/reference/uploadfield

    401 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.