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.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

watermark over an image?


Go to End


2 Posts   1410 Views

Avatar
janulka

Community Member, 80 Posts

27 February 2011 at 8:04pm

Hello,

I have following FittedImage.php:

<?php
class FittedImage extends Image {

function generateMainImage($gd) {
$gd->setQuality(85);
return $gd->resizeRatio(600,600);
}

function generateThumbImage($gd) {
$gd->setQuality(85);
return $gd->resizeRatio(150,150);
}

}
?>

Then I have new dataobject, called product, where:

...
static $has_one = array (
		'ProductImage' => 'FittedImage'
	);
...

And in template I am using

...
<a href="$ProductImage.MainImage.URL" class="fancybox"><img src="$ProductImage.ThumbImage.URL" alt="$ProductName" /></a>
...

What I would like to do, is to place small watermark (images/thumb-watermark.png) over thumb image and larger watermark (images/main-watermark.png) over main image.

How do I do that? I found this topic: http://silverstripe.org/archive/show/275 but I have no idea what to do with the code. What do I put in the FittedImage.php and where do I put it, and what do I use in the template?

Thanks a lot!

Avatar
janulka

Community Member, 80 Posts

3 March 2011 at 11:00am

anybody plz?