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.

General Questions /

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

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

watermark over an image?


Reply


2 Posts   946 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?