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

Refer to other page's image


Go to End


3 Posts   882 Views

Avatar
Arth

Community Member, 4 Posts

8 November 2011 at 9:49pm

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?

Avatar
UncleCheese

Forum Moderator, 4102 Posts

9 November 2011 at 11:14am

Edited: 09/11/2011 11:29am

WatermarkFile()->Filename.

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

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

Avatar
Arth

Community Member, 4 Posts

18 November 2011 at 2:52am

Thank You UncleCheese, it works well now.