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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Replace File in DOM generates File-Object, instead the replaced File-Type


Go to End


2 Posts   1968 Views

Avatar
mtz

Community Member, 17 Posts

18 September 2009 at 10:24pm

I've checked the new DOM and it works great but i think i found a little Bug.

When I Replace an Image in the Admin-Pop-Up, I don't get an Image-File-Object back. Instead its a File-Object.

Now my workaround is an if-condition like

if(!($img->Attachment() == 'FLV' || $img->Attachment() == 'File')){...}

did I do something wrong in the DOM installation?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

18 September 2009 at 11:48pm

You may have found a hole, here.

First, AssetAdmin has never supported replacement of files, so this is an entirely new feature that the DOM is adding to AssetAdmin. The standard AssetAdmin has a custom uploader that, like DOM, sniffs out image types on upload and saves them accordingly.

When replacing a file using the FileIFrameField in the popup, we're using a completely different uploader that needs to be fed the file class ahead of time, e.g.:

$has_one('MyFile' => 'Image');

new FileIFrameField('MyFile');

In this case, the field has all the information it needs to feed the controller the necessary metadata about the type of file being uploaded. What you're saying is that the uploader now needs to be smart enough to ignore the classname that is casted and "upgrade" it to an image when necessary. The DOM bulk uploader, being custom code, is smart enough to do that, but with the replace field, we're dealing with a black box, unfortunately.

Did you in fact get it working? If so show me your changes so I can ratify and add to the module.