Support » Plugin: AMP » Invalid layout specified by its attributes ‘height’

  • Resolved beagin

    (@beagin)


    Performed the plugin update a few days ago, now Google Search Console invalidated every AMP page on this site.

    <div class="embed-vidweb"><amp-iframe id="NATCOM_iframe" src="https://vidweb.com/embedcfg/izmqP6DO9n/&idioma=ES&producto=FYI&p=40932" width="auto" height="" frameborder="0" scrolling="no" allowfullscreen="" layout="fixed-height" sandbox="allow-scripts allow-same-origin"><span placeholder="" class="amp-wp-iframe-placeholder"></span><noscript><iframe id="NATCOM_iframe" src="https://vidweb.com/embedcfg/izmqP6DO9n/&idioma=ES&producto=FYI&p=40932" width="100%" height="100%" frameborder="0" scrolling="no"></iframe></noscript></amp-iframe></div>
    

    The error according to Google is: The mandatory attribute ‘height’ is missing in tag ‘amp-iframe’ in class embed-vidweb.

    • This topic was modified 1 month, 2 weeks ago by beagin.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Weston Ruter

    (@westonruter)

    Please share an example URL for where this can be seen.

    We also need to see the non-AMP version to see what it is being converted from.

    We have a pull request open which will likely fix this: https://github.com/ampproject/amp-wp/pull/3728

    But we need more details to determine if that is the case.

    Version desktop
    link desktop

    Version AMP

    Link amp

    • This reply was modified 1 month, 2 weeks ago by beagin.
    Plugin Author Weston Ruter

    (@westonruter)

    Gracias.

    In the non-AMP version I can see this code:

    <div class="embed-vidweb"><iframe id="NATCOM_iframe" src="//vidweb.com/embedcfg/izmqP6DO9n/&idioma=ES&producto=FYI&p=40932" width="100%" height="100%" frameborder="0" scrolling="no" allowfullscreen="allowfullscreen"></iframe></div>

    There is a bug in the AMP plugin here where it is failing to apply the fill layout to the amp-iframe.

    You can fix this by patching the AMP plugin with this change:

    --- a/includes/sanitizers/class-amp-base-sanitizer.php
    +++ b/includes/sanitizers/class-amp-base-sanitizer.php
    @@ -321,7 +321,10 @@ abstract class AMP_Base_Sanitizer {
     			$attributes['height'] = self::FALLBACK_HEIGHT;
     		}
     
    -		if ( empty( $attributes['width'] ) || '100%' === $attributes['width'] ) {
    +		if ( isset( $attributes['width'], $attributes['height'] ) && '100%' === $attributes['width'] && '100%' === $attributes['height'] ) {
    +			$attributes['layout'] = 'fill';
    +			unset( $attributes['width'], $attributes['height'] );
    +		} elseif ( empty( $attributes['width'] ) || '100%' === $attributes['width'] ) {
     			$attributes['layout'] = 'fixed-height';
     			$attributes['width']  = 'auto';
     		}

    Please confirm this fixes the issue for you.

    We’ll make sure this fix gets included in the next version of the AMP plugin via this pull request: https://github.com/ampproject/amp-wp/pull/3728

    Thanks, I have done the tests and the code settings are working correctly.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.