Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Related: That can be done on the server-side too.

https://blog.uidrafter.com/conditional-avif-for-video-poster...



> Unlike <img> tags, <video> posters have no standard way of specifying many URLs for fetching the optimal format supported by the client.

Actually, you can do it without needing any scripting, though the technique is convoluted: use as the poster an SVG image (encoded inline as a data URI), containing a <foreignObject>, containing an HTML <picture> element. It ends up roughly this (with superfluous whitespace added):

  <video
    poster='data:image/svg+xml,
      <svg xmlns="http://www.w3.org/2000/svg" …>
          <foreignObject …>
              <picture xmlns="http://www.w3.org/1999/xhtml">
                  …
              </picture>
           </foreignObject>
      </svg>
    '>
  </video>


Thank you. This is handy for requesting with options besides the image format.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: