@@ -251,21 +251,52 @@ of transformation directives offered by
251251<Img {src} alt =" cat" />
252252```
253253
254- ### Art direction
254+ ### Responsive Image Sizes
255255
256256Use the ` sizes ` attribute to define media conditions that provide hints as to which image size to
257- select when those conditions are true. Read up more on the
258- [ art direction problem ] ( https://developer.mozilla.org/en-US/docs/Learn /HTML/Multimedia_and_embedding/Responsive_images ) .
257+ select when those conditions are true. Read up more on
258+ [ responsive images and the picture element ] ( https://developer.mozilla.org/en-US/docs/Web /HTML/Element/picture ) .
259259
260- <!-- prettier-ignore -->
261260``` html
262261<script >
263- import src from ' $lib/a/cat.jpg?w=480;800as =run
262+ import src from ' $lib/a/cat.jpg?w=480;800&as =run'
264263 import Img from ' @zerodevx/svelte-img'
265264 </script >
266265
267- <!-- If viewport is <=600px, use 480px as viewport width -->
268- <Img {src} alt="cat" sizes="(max-width: 600px) 480px, 800px" />
266+ <!-- When the viewport is <=600px, tell the browser's image preloader that once the CSS for our
267+ design has been parsed and applied, we expect the width of the image in our design to be 480px -->
268+ <img {src} alt =" cat" sizes =" (max-width: 600px) 480px, 800px" />
269+ ```
270+
271+ Renders into:
272+
273+ ``` html
274+ <picture >
275+ <source
276+ type =" image/avif"
277+ sizes =" (max-width: 600px) 480px, 800px"
278+ srcset =" path/to/avif-480 480w, path/to/avif-800 800w"
279+ />
280+ <source
281+ type =" image/webp"
282+ sizes =" (max-width: 600px) 480px, 800px"
283+ srcset =" path/to/webp-480 480w, path/to/webp-800 800w"
284+ />
285+ <source
286+ type =" image/jpeg"
287+ sizes =" (max-width: 600px) 480px, 800px"
288+ srcset =" path/to/jpeg-480 480w, path/to/jpeg-800 800w"
289+ />
290+ <img
291+ alt =" cat"
292+ width =" 800"
293+ height =" 600"
294+ loading =" lazy"
295+ decoding =" async"
296+ src =" path/to/jpeg-800"
297+ style =" background : url (data:image/webp;base64,XXX ) center center / cover no-repeat ;"
298+ />
299+ </picture >
269300```
270301
271302### Lazy loading
0 commit comments