Exclude image with low width?
-
Hi,
I am trying to exclude some images and using this filter but it doesn’t work (exclude image which has width < 500).
Please help!
/** * This filter allows to programatically prevent watermarking certain * attachment if <code>false</code> returned from attached function. * * @param boolean $should_apply Whether the image should be watermarked. Return false to prevent watermarking. * @param Watermark $watermark Watermark object. * @param integer $attachment_id Attachment ID. * @param WP_Post $attachment Attachment post. * @param array $meta Attachment metadata. * @param array $applied_watermarks Array containing all watermarks applied to this attaachment. * */ add_filter( 'easy-watermark/should-apply-watermark','dont_watermark', 10, 6 ); function dont_watermark ($is_watermark, $watermark, $attachment_id, $attachment, $meta, $applied_watermarks) { //$meta = wp_get_attachment_metadata($attachment_id); //echo 'tada'; //$title = 'Image Debug'; $width = $meta['width']; // $message = '300px'; // //$parent = 1; // This might be the ID of a payment post type item we want this log item connected to // //$type = 'event'; // //WP_Logging::add( $title, $message, $parent, $type ); // WP_Logging::add( $title, $message ); if( $meta['width'] < 500 ) { $is_watermark = false;//no WM } else { $is_watermark = true; } return $is_watermark; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Exclude image with low width?’ is closed to new replies.