Watermarks for your Content Images, without using a WordPress Watermark Plugin.

image editing 8 Kommentare

There is an easy way to automatically integrate WordPress Watermark on your Content Images. You just need a small script and an additional line in your .htaccess

Disclaimer

If you need WordPress help, you can find advice on wordpress.stackexchange.com, where I post regularly as fischi. I do not provide support here.

Save the script as „watermark.php“. Feel free to alter the parameters, every parameter for the watermarks is explained in the code.

The code for creating the Watermark

 

Now you have to alter your .htaccess: Insert the line below. This example is to be used for WordPress, if you don’t want to use a WordPress Watermark Plugin or if you can’t find one that fulfills your needs.
Of course, this script can be used with any other CMS as well: it ddoesn’t matter if it’s Wrdpress, Joomla, SixCMS, Drupal or anything else. The trick is to redirect the images from your upload directory to the watermark.php with a regular expression, and pass the source of the image on with a GET parameter.
ATTENTION! Please do not use this script on every image, because the images in your templates should not be affected by an automatic watermark integration. If you want to do this on purpose, no problem. But it makes no sense to have a Watermark on your icons 😉

The code for enabling WordPress Watermark in your system

Have Fun!
Sometimes it pays off to know PHP, and not just making a collection of WordPress Plugins 🙂 I think most WordPress Watermark Plugins are to inflexible or broken, and if you integrate the Watermark on the upload, you have no possibility to change them, for example if your customerr changes his logo. If you integrate the Watermark on the fly, you should not have a problem with that.
Another plus: You are not dependent on the ongoing improvement of a specific WordPress Watermark Plugin!

Have a nice Day,

fischi.

This was a long time ago… My page looked like this:

wordpress watermark - programmieren seit jahren

8 Responses to “Watermarks for your Content Images, without using a WordPress Watermark Plugin.”

  1. Jamesabran Antworten

    Does this work with woocommerce products? and how do you go by applying to product images only. Excluding all non-product images?

    • Thomas Fischer Antworten

      Hi, this version does not really work for filtering, as all media is processed.
      You have a few possibilities – if your productimages are a specific size, you can create a Watermark for those, and not for the other pictures. You will need to have something to identify which picture is a product picture, then this is no problem.

  2. fery Antworten

    hello fischi
    i am create watermark.php file and copy source to file
    and create empty png and watermark png and set to watermark.php
    and set rewrite code to htaccess
    but test it . and not show image in content. my image is broken .
    my image is default wordpress: wp-content/uploads

    test in firefox show error:
    The image “http://mysite.com/wp-content/uploads/2012/04/apple-firstquarter-earnings-report-2012.jpg” cannot be displayed because it contains errors.

    please help me for solve problem
    thank you

    • fischi Antworten

      Hi Monica!

      Sorry for the delayed answer, but i was on internet and phonefree holiday 🙂
      Do i understand that correctly, that you want to add another directory to add the watermark?

      you already have http://www.example.com/wp-content/uploads done with watermarks, so if you want to have http://www.example.com/tryme to have the watermark, you have to add this line to your .htaccess file:

      RewriteRule ^(.*)tryme/(.*) $1watermark.php?src=tryme/$2

      now you are all set!

      cheers

      fischi

Hinterlasse eine Antwort