Title: Watermark without plugins
Last modified: August 22, 2016

---

# Watermark without plugins

 *  Resolved [biryuk](https://wordpress.org/support/users/biryuk/)
 * (@biryuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/watermark-without-plugins/)
 * Hello, I make adding watermark when image is loading into medialibrary. For that
   I use “add_attachment” hook:
    `add_action('add_attachment', 'applyWatermark');`
   My trouble is thumbnails has watermark too. I want that they didn’t have it. 
   I suspect that need find other hook who will executed after create thumbnail 
   function but I can’t find it. Or exist other way perhaps?
 * Handler function “applyWatermark” if is needed:
 *     ```
       function applyWatermark($attachId)
       {
         if (wp_attachment_is_image($attachId)) {
   
           $attachPath = get_attached_file($attachId);
           $templatePath = get_bloginfo('template_directory');
   
           $im = imagecreatefromjpeg($attachPath);
           $stamp = imageCreateFromPng($templatePath.'/watermarks/wm.png');
   
           $marge_right = 10;
           $marge_bottom = 10;
           $sx = imagesx($stamp);
           $sy = imagesy($stamp);
           imageAlphaBlending($stamp, false);
           imageSaveAlpha($stamp, true);
   
           imagecopy($im, $stamp, imagesx($im) - $sx - $marge_right, imagesy($im) - $sy - $marge_bottom, 0, 0, imagesx($stamp), imagesy($stamp));
   
           imagejpeg($im, $attachPath);
           imagedestroy($im);
         }
   
         return $attachId;
       }
       ```
   

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [PhPCentre](https://wordpress.org/support/users/phpcentre/)
 * (@phpcentre)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/watermark-without-plugins/#post-5916206)
 * Use this `wp_generate_attachment_metadata` filter, it fires after creating thumbnails.
 *  Thread Starter [biryuk](https://wordpress.org/support/users/biryuk/)
 * (@biryuk)
 * [11 years, 2 months ago](https://wordpress.org/support/topic/watermark-without-plugins/#post-5916307)
 * Thank you, it works! You really helped me

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Watermark without plugins’ is closed to new replies.

## Tags

 * [hook](https://wordpress.org/support/topic-tag/hook/)
 * [watermark](https://wordpress.org/support/topic-tag/watermark/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [biryuk](https://wordpress.org/support/users/biryuk/)
 * Last activity: [11 years, 2 months ago](https://wordpress.org/support/topic/watermark-without-plugins/#post-5916307)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
