How can I add an image watermark to only those images which are to be published in gallery using a function in functions.php
? Images can be in .jpg
, .png
, .gif
format.
I also found this snippet which serves the same but it watermarks all the uploaded images.
This is what I put into a
watermark.php
file :?>
then into a
.htaccess
file :Place the
watermark.php
+.htaccess
+watermark.png
intowp-content/uploads
folder (or any other place if you adapt the.htaccess
line).Here the .htaccess grabs any request for jpg, png ou gif that contains 800x or x800 in the name (to apply watermark on big images only), redirect it to the
watermark.php
script who add the watermark on the image.This is a starter that you should adapt to your needs by defining the rules to apply in the
.htaccess
file. For our case, we had define 800×800 size in the media options.