Jump to:

3430 Posts in 1057 Topics by 734 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Adding an image to a DataObject from a file

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

Page: 1
Go to End
Author Topic: 2047 Views
  • nostradamus1935
    Avatar
    Community Member
    9 Posts

    Adding an image to a DataObject from a file Link to this post

    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.

  • nostradamus1935
    Avatar
    Community Member
    9 Posts

    Re: Adding an image to a DataObject from a file Link to this post

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

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