Next.js: Amp-image fallback leads to validation error

Created on 9 Jan 2020  路  3Comments  路  Source: vercel/next.js

Bug report

Describe the bug

When specifying an amp-image fallback image according to the amp documentation, the parameter fallback is converted to fallback="true" and amp-validator returns "The attribute 'fallback' in tag 'amp-img' is set to the invalid value 'true'."

To Reproduce

  1. Add a new amp page
  2. Add an amp-image with fallback (https://amp.dev/documentation/components/amp-img/#example:-specifying-a-fallback-image):
<amp-img
    alt="Mountains"
    width="550"
    height="368"
    src="https://amp.dev/static/inline-examples/images/mountains.webp"
    >
    <amp-img
        alt="Mountains"
        fallback
        width="550"
        height="368"
        src="https://amp.dev/static/inline-examples/images/mountains.jpg"
    ></amp-img>
</amp-img>
  1. Run amp-validator

Expected behavior

The validation succeeds

System information

good first issue

Most helpful comment

@timneutkens
The document about AMP Pages might have to be updated.
Add "" value to the attribute 'fallback' , 'placeholder' and so on.

馃憣

<amp-img
        alt="Mountains"
        fallback=""
        width="550"
        height="368"
        src="https://amp.dev/static/inline-examples/images/mountains.jpg"
    ></amp-img>

馃憥

<amp-img
        alt="Mountains"
        fallback
        width="550"
        height="368"
        src="https://amp.dev/static/inline-examples/images/mountains.jpg"
    ></amp-img>

All 3 comments

The related document
Placeholders & fallbacks - amp.dev

In amp-html, the attributes fallback and placeholder disallow any value.
The cause of this problem is the parser adding true value automatically.

Example was updated recently

@timneutkens
The document about AMP Pages might have to be updated.
Add "" value to the attribute 'fallback' , 'placeholder' and so on.

馃憣

<amp-img
        alt="Mountains"
        fallback=""
        width="550"
        height="368"
        src="https://amp.dev/static/inline-examples/images/mountains.jpg"
    ></amp-img>

馃憥

<amp-img
        alt="Mountains"
        fallback
        width="550"
        height="368"
        src="https://amp.dev/static/inline-examples/images/mountains.jpg"
    ></amp-img>
Was this page helpful?
0 / 5 - 0 ratings