amphtml: [amp-video] media queries do not filter poster images

This is bad: poster images ignore the media attribute and are always downloaded.

Example:

<amp-video layout="responsive" width=640 height=480 media="(max-width: 767px)" src="https://ampbyexample.com/video/tokyo.mp4?video=10" poster="https://unsplash.it/640/480?image=10"></amp-video>
<amp-video layout="responsive" width=640 height=480 media="(min-width: 768px)"  src="https://ampbyexample.com/video/tokyo.mp4?video=12" poster="https://unsplash.it/1024/768?image=11"></amp-video>

Expected behavior: 1 poster image and 1 video will be downloaded depending on screen width. Actual behavior: 2 poster images and 1 video are downloaded depending on screen width.

Live sample: https://jsbin.com/powatilomu/edit?html,output

Both poster images are downloaded:

screen shot 2018-03-27 at 10 55 10

//cc @aghassemi

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (13 by maintainers)

Most upvoted comments

Pinging this again. Quick reminder how bad this is: if you load https://www.bmw.com/ this bug results in 180kb of unneeded preview image downloads.