Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter srcset feature broken #10

Open
robertstaddon opened this issue Sep 22, 2022 · 0 comments
Open

Filter srcset feature broken #10

robertstaddon opened this issue Sep 22, 2022 · 0 comments

Comments

@robertstaddon
Copy link

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/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant