You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The “Filter srcset” feature on the “Settings” tab is broken with the current 1.0.11 version of Easy Watermark on the WordPress repository. 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 but your latest develop branch appears to be 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 “Filter srcset” feature on the “Settings” tab is broken with the current 1.0.11 version of Easy Watermark on the WordPress repository. 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 but your latest develop branch appears to be 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.
Here's my corresponding post about this issue on the WordPress support forum: https://wordpress.org/support/topic/filter-srcset-feature-broken/
The text was updated successfully, but these errors were encountered: