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.

Data Model Questions /

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

Cast a File object to Image


Go to End


1223 Views

Avatar
martinBE

Community Member, 2 Posts

18 October 2011 at 9:25pm

Edited: 19/10/2011 9:28pm

Hi
how can I cast a File object to Image object? Either in the controller or in the view. I did not find a constructor or something similar in the Image class. I need the resizing methods from the Image class.

Thanks in advance
Martin

EDIT:
Maybe I expressed the problem unclear. I have an Image gallery where I only save the folder name and display all included image files. I now solved this by querying directly for images:

$images = DataObject::get("Image", "Filename LIKE '%$escaped_folder%'", "NAME");

But I would be interested if it is poosible to cast a Object<ViewableData<DataObject<File into Object<ViewableData<DataObject<File<Image