-
Notifications
You must be signed in to change notification settings - Fork 179
Description
Currently, the Transcoder does not generate the required three image variants at the specified widths (360px, 640px, 960px).
For proper responsive image handling, the implementation should leverage the srcset and sizes attributes, which allow the browser to automatically select the most appropriate image based on the user’s device resolution and viewport width.
A correct implementation example:
<img class="card__media"
src="https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=640&h=427&q=80&crop=entropy"
srcset="https://images.unsplash.com/...&w=320&h=213&q=80&crop=entropy 320w,
https://images.unsplash.com/...&w=640&h=427&q=80&crop=entropy 640w,
https://images.unsplash.com/...&w=960&h=640&q=80&crop=entropy 960w"
sizes="(min-width: 1280px) 360px,
(min-width: 768px) calc(50vw - 48px),
100vw"
alt="Blue hour light..."
fetchpriority="high">
Explanation of key parts:
src – Provides a fallback/default image (here at 640px).
srcset – Defines multiple image variants (320w, 640w, 960w) with consistent aspect ratio.
sizes – Instructs the browser how much space the image will occupy depending on viewport:
For screens ≥1280px → use 360px wide image.
For screens ≥768px → use half the viewport width minus 48px.
For smaller screens → scale to full viewport width (100vw).
fetchpriority="high" – Ensures the image is prioritized for loading, which is especially important for above-the-fold content.