Filter srcset feature broken
-
The “Filter srcset” feature on the “Settings” tab is broken with the current 1.0.11 version of Easy Watermark. It does not filter out the srcset attribute to only contain image sizes watermarked the same way.
The reason for this is that the “_ew_applied_watermarks” meta key that you are storing on each media item is an array with the $watermark_id as the key and the name as the value. However, the “get_allowed_sizes” function in your SrcsetFilter class (/src/classes/Features/SrcsetFilter.php) does a foreach on $watermarks as $watermark_id, which assigns it the name of the watermark and not the ID. This fails when you call Watermark::get, which is expecting the ID instead of the name.
The fix is simple, just change Line 159 to the following and your “Filter srcset” feature works again:
foreach ( $watermarks as $watermark_id => $watermark_name ) {
With the above change, the $watermark_id variable then holds the array key, which is the actual watermark ID (and not the name), and this is exactly what your Watermark::get function needs.
I would submit a pull request with this simple change on your Github page but your latest develop branch is at 1.0.6. If you would like to update it, I would be happy to fork your code and submit this as a pull request.
- The topic ‘Filter srcset feature broken’ is closed to new replies.