amp-htmlamp-img

Why does the parent element of source tag need to be amp-video?


On the amp docs https://www.ampproject.org/docs/reference/validation_errors it says that source requires a media tag (amp-audio, amp-video, etc.).

I have a picture tag with multiple source elements but when I try to transform it to amp-img I get the error that it needs to be amp-video.

Do you know why it doesn't accept amp-img as its parent element? Is it not considered to be a media tag.


Solution

  • I think you are trying to define different image URLs for certain resolutions/sizes. Have a look at the srcset attribute of <amp-img>. There's an example here:

    https://ampbyexample.com/components/amp-img/