Jump to:

7937 Posts in 1537 Topics by 944 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » Refer to other page's image

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1
Go to End
Author Topic: 328 Views
  • Arth
    Avatar
    Community Member
    4 Posts

    Refer to other page's image Link to this post

    Hi All,

    I'm working on a service page for the site admins. They will be able to change the uploaded image's watermark on this CMS page

    So I included the watermark size (percentage) and the image to service page:

    class Szerviz extends Page {

       public static $db = array(
          'LogoPercent' => 'Int',
       );

       public static $has_one = array(
          'WatermarkFile' => 'Image',
       );
    ....

    From the ImageDecorator.php I can reach only the image size, but the image not. My code:

    class ImageDecorator extends DataObjectDecorator {

       function onAfterWrite(){
    ...
    $logo_percent=DataObject::get_one('Szerviz')->LogoPercent; //works

    //it doesn't work:
    $watermark = imagecreatefrompng(str_replace('/','\\',Director::baseFolder()
    .'/'.DataObject::get_one('Szerviz')->WatermarkFile->Filename));

    What's wrong?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Refer to other page's image Link to this post

    WatermarkFile()->Filename.

    Although, given the context, I'd probably use WatermarkFile()->getFullPath();

    --------------------
    SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

  • Arth
    Avatar
    Community Member
    4 Posts

    Re: Refer to other page's image Link to this post

    Thank You UncleCheese, it works well now.

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