Coded something up in Couch in an interesting way? Have a snippet or shortcode to share? Post it here for the community to benefit.
10 posts Page 1 of 1
This is a little addon that can be used to watermark uploaded images.
watermark.zip
(2.91 KiB) Downloaded 338 times

https://github.com/CouchCMS/Watermark


Installation:
a. Download the attached zip. Expanding it will yield a folder named 'watermark'.
b. Within the folder is an image named 'watermark.png'. This is the default image that will be used to watermark other images. Replace it with a PNG file of your own with the same name (IMP: this image has to be a PNG. Transparency and opacity are allowed)
c. Place this folder in 'couch/addons' folder.
d. Edit 'couch/addons/kfunctions.php' (if not found, rename the 'kfunctions.example.php' to 'kfunctions.php') and
add the following line to it:
Code: Select all
require_once( K_COUCH_DIR.'addons/watermark/watermark.php' );


Usage:
The installed addon exposes a single tag named 'cms:watermark'.

Given the full path of an image, as in the following snippet
Code: Select all
<cms:watermark src='http://www.mysite.com/couch/uploads/image/test.jpg' />

this tag will create a watermarked version of the specified image (by creating a copy of the image in the same folder and superimposing the watermark over it) and output this watermarked image's path.

The proper way to use this tag's output in a template would be in tandem with the HTML 'img' tag - something like this
Code: Select all
<img src="<cms:watermark src='http://www.mysite.com/couch/uploads/image/test.jpg' />" />

Instead of hardcoding the source image's path, as we did above, we are more likely to provide the output of an editable region of type image as this tag's source.

If, for example, the name of an image type region is 'my_image', this is how we would output the image on the front-end
Code: Select all
<img src="<cms:show my_image />" />

and this is how we create and output the above image's watermarked version
Code: Select all
<img src="<cms:watermark my_image />" />


Parameters:
    image
    with
    at
    suffix
    check_exists

image
URL of the image to watermark. This image has to be within Couch's designated 'uploads' folder.
Code: Select all
<cms:watermark image=my_image />
or
Code: Select all
<cms:watermark my_image />


with
The name of the PNG file used as the watermark.
The specified file should reside within the 'couch/addons/watermark' folder
If not specified, the default 'watermark.png' is assumed.
Code: Select all
<cms:watermark my_image with='my_watermark.png' />


at
Position where the watermarkis applied on the image.
Acceptable values are
    top_left
    top_center
    top_right
    middle_left
    middle
    middle_right
    bottom_left
    bottom_center
    bottom_right

If none specified, the default 'bottom_right' is assumed.
Code: Select all
<cms:watermark my_image with='my_watermark.png' at='bottom_left' />


check_exists
By default this parameter has a value of '1' which makes the tag first check if the watermarked version exists before creating it afresh. If one exists (because of a previous execution of this tag), no further processing takes place and the existing version is returned.

You can set this parameter to '0' during testing phase (e.g. testing the placement of the watermark) so that a new watermarked image gets created with every run.
Code: Select all
<cms:watermark my_image with='my_watermark.png' at='bottom_left' check_exists='0' />

IMP: Do set the parameter back to '1' (or remove it altogether) once the site goes live as it incurs unnecessary processing.

As always, feedback solicited :)
Thanks for addon. Adding to my addon list, will test it out!
Wow!!
exactly what I needed! Works beautifully, such a straight forward no nonsense addon!!

Kudos
I'm not primitive, My time machine just malfunctioned in your era.
Had a couple of problems, but test went out.

Didn't work great with older filetypes (jpeg), but that's no biggie. Worked with zoomable galleries, other scripts without any noticable issue

Is there a possibility to more like watermark permanently - aka displaying the

Any input on SEO purposes - such as Images for Google getting watermarked files instead of typical ones? Will it take qwe__wm__.jpg ?

Kudos.
Wow, nice tool!
It would save me a lot of work not having to place the watermark manually on every photo!
I guess I'll try to make an editable dropdown field for the watermark location, so I can pick the best location for each picture individually!
But I was wondering if there was any way to make the original image inaccessible for non-admins, since the whole point of watermarking is not giving away the original?
You can use cloak_url to obfuscate the original name of the watermarked image.
Code: Select all
<img src='<cms:cloak_url link="<cms:watermark my_image />" />' alt="" />
Hello everybody! How can I use the ADDON in this case:
Code: Select all
<cms:show_repeatable 'my_images'>                           
    <img src="<cms:thumbnail my_image width='880' />" >
</cms:show_repeatable>

Thank you!
Jiwa wrote: Hello everybody! How can I use the ADDON in this case:
Code: Select all
<cms:show_repeatable 'my_images'>                           
    <img src="<cms:thumbnail my_image width='880' />" >
</cms:show_repeatable>

Thank you!


<cms:watermark "<cms:thumbnail my_image width='880' />" />
It worked! Thank you! :)
Hi,
I see that this addon has a problem with PHP7:

Code: Select all
[20-Jul-2017 14:12:00 Europe/Sofia] PHP Warning:  require_once(/home/mototec1/public_html/panel/addons/watermark/watermark.php): failed to open stream: No such file or directory in /home/my_site/public_html/panel/addons/kfunctions.php on line 14

[20-Jul-2017 14:12:00 Europe/Sofia] PHP Fatal error:  require_once(): Failed opening required '/home/mototec1/public_html/panel/addons/watermark/watermark.php' (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/my_site/public_html/panel/addons/kfunctions.php on line 14


It would be good to fix it :)
Thanks
10 posts Page 1 of 1

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest

cron