Removes javascript events on img tags
-
I found an 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:
# 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%s%s%s%s%s%s%s%s%s width="%s" height="%s">', $src, $srcset, $longdesc, $alt, $class, $id, $usemap, $align, $border, $hspace, $vspace, $crossorigin, $ismap, $sizes, $title, $onmouseover, $onmouseout, $onclick, $onkeypress, $style, $width, $height );
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Removes javascript events on img tags’ is closed to new replies.