Support » Plugin: AMP » Disallowed attribute in HTML tag ‘img’

  • I had no issue with a different AMP plugin before, and I switched to this one here only because of the Yoast integration. Since then I get error reports from Google Search console with AMP errors for every page: Disallowed attribute in HTML tag ‘img’

    If this is a problem related to this plugin, would the author please fix it immediately?? Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Contributor Ryan Kienstra


    Thanks For The Feedback

    Hi @volkerforster,
    Thanks for letting me know about the error in the Google search console. Do you still have the plugin active, and if so, could you please share the URL where that issue exists? I’d like to see if I can help you fix it.

    thank you for the responds. Just one example would be

    This forum seems not to have any option to add a picture…? Therefore, I am unable to send a screenshot of Google’s Issue Detail Page.

    Plugin Contributor Ryan Kienstra


    Hi @volkerforster,
    Thanks for the URL. If you’d like to add a picture, you could paste in a link from CloudUp if you have an account.

    It looks like another plugin or theme may be filtering the featured image markup to add a <noscript> with that disallowed image.
    Image in noscript

    It may be doing something like:

    add_filter( 'post_thumbnail_html', ...

    Here’s that filter in Core:

    It looks like the site uses the WPBakery Page Builder plugin. That’s a paid plugin, so it’s hard for me to debug it.

    If you’re willing, it’d be great if you could search all of your plugins for post_thumbnail_html.

    I’ll also see if we could do something on our side to prevent that image from appearing in the <noscript>.

    the string was found 5 times:






    Any help?

    Hopefully there is a fix, otherwise I must switch back to the AMP plugin I used before I switched to AMP for WordPress. I can’t risk to lose my ranking and to have my AMP pages kicked out of the Google index.

    Plugin Contributor Ryan Kienstra


    Suggested Workaround

    Hi @volkerforster,
    Thanks a lot for your patience, and for listing your plugins. The SEO Friendly Images Pro for WordPress plugin seems to be adding a <noscript> tag with that <img>, and that <img> had an invalid value that this AMP plugin didn’t strip.

    Here’s a workaround that you could place in your theme’s functions.php file, or a custom plugin. It worked for me locally:

    add_action( 'wp', function() {
    	if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) {
    		remove_filter( 'post_thumbnail_html', array( 'pbSEOFriendlyImagesPro', 'lazyLoadImages') );
    } );

    Could you please let me know if this works for you? Thanks!

    • This reply was modified 2 years, 6 months ago by Ryan Kienstra.

    when I add this action to the function.php my website does not work anymore and shows the error:

    Parse error: syntax error, unexpected ‘&’ in /home/univer73/public_html/universalsolder/wp-content/themes/thegem/functions.php on line 2572

    Plugin Contributor Ryan Kienstra


    Hi @volkerforster,
    Thanks, that must be frustrating.

    Are the single quotes ' appearing in your editor as carets like `, by chance?

    Though it’s not usually best practice, it might help to try converting all of the single quotes to double quotes ".

    Oh… of course, sorry. I did it in a rush and did not realize the nonsense Windows notepad does. Now I used Notepad++, and it works fine.

    The AMP test was successful as well.

    Thanks a lot!

    Plugin Contributor Ryan Kienstra


    Hi @volkerforster,
    Thanks for your patience, and it’s great that there’s no AMP error now.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Disallowed attribute in HTML tag ‘img’’ is closed to new replies.