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.

Data Model Questions /

Adding an image to a DataObject from a file


Reply


2 Posts   2116 Views

Avatar
nostradamus1935

Community Member, 9 Posts

9 June 2010 at 6:45am

Hi,

I have a DataObject, a DocumentObject, that contains many informations, but most importantly for my question : a File object (or more precisely a PDF object that restricts to pdfs and has a template) and an Image. I want the Image, a thumbnail actually, to be automatically generated from the document. I'm using imagemagick to do this.

For the moment, I'm generating the image and putting it in a predictable place and then find it... by knowing where it is. That's clearly not the proper way to do it, since I can't access SS gd functions or query any information from this image to use it dynamically in the template, etc.

I've been looking at the loadUploadedImage($tmpFile) function in Image... but haven't been sucessful in using it to join my generated image to the Image object (I'm guessing that's what it's for). For the moment, the image is generated in onBeforeWrite of the DataObject, I'm pretty that's where I must join it too.

So, do you have any experience in doing this or would you have any idea on the way to do it ?

Thanks.

Avatar
nostradamus1935

Community Member, 9 Posts

11 June 2010 at 8:58am

You may want to check this : http://silverstripe.org/data-model-questions/show/286020 . Found by myself after all.