Skip to content

Commit c8652ec

Browse files
committed
refactor: sort srcset images
1 parent f502cee commit c8652ec

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

docs/2-Content.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,8 @@ Could be converted to:
325325

326326
```html
327327
<picture>
328-
<source srcset="/image.avif" type="image/avif">
329328
<source srcset="/image.webp" type="image/webp">
329+
<source srcset="/image.avif" type="image/avif">
330330
<img src="/image.jpg">
331331
</picture>
332332
```
@@ -349,9 +349,9 @@ will be converted to:
349349

350350
```html
351351
<img src="/thumbnails/800/image.jpg" width="800" height="600"
352-
srcset="/thumbnails/800/image.jpg 800w,
352+
srcset="/thumbnails/320/image.jpg 320w,
353353
/thumbnails/640/image.jpg 640w,
354-
/thumbnails/320/image.jpg 320w"
354+
/thumbnails/800/image.jpg 800w"
355355
sizes="100vw"
356356
>
357357
```

src/Asset/Image.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public static function buildHtmlSrcset(Asset $asset, array $widths, $notEmpty =
258258
continue;
259259
}
260260
$img = $asset->resize($width);
261-
$srcset .= \sprintf('%s %sw, ', (string) $img, $width);
261+
$srcset = \sprintf('%s %sw, ', (string) $img, $width) . $srcset;
262262
$widthMax = $width;
263263
}
264264
// adds source image

src/Converter/Parsedown.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,11 @@ protected function inlineImage($Excerpt)
374374
<figure>
375375
<!-- if formats: a <picture> is required for each <source> -->
376376
<picture>
377-
<source type="image/avif"
377+
<source type="image/webp"
378378
srcset="..."
379379
sizes="..."
380380
>
381-
<source type="image/webp"
381+
<source type="image/avif"
382382
srcset="..."
383383
sizes="..."
384384
>

0 commit comments

Comments
 (0)