Skip to content

Commit

Permalink
Use jpeg source files as fallback rather than converting to png (#9010)
Browse files Browse the repository at this point in the history
Co-authored-by: Erika <[email protected]>
  • Loading branch information
2 people authored and natemoo-re committed Nov 22, 2023
1 parent 3f12f34 commit 882eee1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/quiet-games-film.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": minor
---

The `<Picture />` component will now use `jpg` and `jpeg` respectively as fallback formats when the original image is in those formats.
3 changes: 2 additions & 1 deletion packages/astro/components/Picture.astro
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ const defaultFallbackFormat = 'png' as const;
// Certain formats don't want PNG fallbacks:
// - GIF will typically want to stay as a gif, either for animation or for the lower amount of colors
// - SVGs can't be converted to raster formats in most cases
// - JPEGs compress photographs and high-noise images better than PNG in most cases
// For those, we'll use the original format as the fallback instead.
const specialFormatsFallback = ['gif', 'svg'] as const;
const specialFormatsFallback = ['gif', 'svg', 'jpg', 'jpeg'] as const;
const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro.props;
Expand Down

0 comments on commit 882eee1

Please sign in to comment.