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.

Customising the CMS /

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

Files not available for extended Image object (SS3)


Go to End


2 Posts   1010 Views

Avatar
JimmyNZ

Community Member, 2 Posts

9 October 2012 at 11:01pm

Edited: 10/10/2012 12:57am

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');

Avatar
martimiz

Forum Moderator, 1391 Posts

24 October 2012 at 12:26am

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