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

Removes javascript events on img tags #3

Open
ethanosullivan opened this issue Feb 22, 2018 · 0 comments
Open

Removes javascript events on img tags #3

ethanosullivan opened this issue Feb 22, 2018 · 0 comments
Assignees
Labels

Comments

@ethanosullivan
Copy link
Member

WordPress user (Sandra) found a bug that make some attributes disappear. So this code turns out like this:

<img id="rating_1952_1" src="https://www.foodcat.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_off.png" alt="1 Stern" title="1 Stern" onmouseover="current_rating(1952, 1, '1 Stern');" onmouseout="ratings_off(0, 0, 0);" onclick="rate_post();" onkeypress="rate_post();" style="cursor: pointer; border: 0px;">
<img src="https://www.foodcat.de/wp-content/plugins/wp-postratings/images/stars_flat(png)/rating_off.png" alt="1 Stern" id="rating_1952_1" width="17" height="16">

Here is the fix she provided:

# Match all image attributes
$attributes = 'src|srcset|longdesc|alt|class|id|usemap|align|border|hspace|vspace|crossorigin|ismap|sizes|title|onmouseover|onmouseout|onclick|onkeypress|style|width|height';

# Recreate the image tag with dimensions set
$tag = sprintf( '<img src=%s%s%s%s%s%s%s%s%s%s%s

Please apply the fix and test locally. Once it works out, then push to production and apply bug fix credit.

Reference: https://wordpress.org/support/topic/removes-javascript-events-on-img-tags/

@ethanosullivan ethanosullivan self-assigned this Feb 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant