summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Caleb Jasik <calebjasik@jasik.xyz> 2023-11-08 03:09:40 -0600
committerGravatar GitHub <noreply@github.com> 2023-11-08 10:09:40 +0100
commit100b61ab5a34c1efc571a57ce46832ece97688e5 (patch)
tree77e3e5be6b61e4cdeb0ce46074443404525eb73a
parent653ad939ce9f0ba12e2ce79a4cf9c154302b0bb9 (diff)
downloadastro-100b61ab5a34c1efc571a57ce46832ece97688e5.tar.gz
astro-100b61ab5a34c1efc571a57ce46832ece97688e5.tar.zst
astro-100b61ab5a34c1efc571a57ce46832ece97688e5.zip
Use jpeg source files as fallback rather than converting to png (#9010)
Co-authored-by: Erika <3019731+Princesseuh@users.noreply.github.com>
-rw-r--r--.changeset/quiet-games-film.md5
-rw-r--r--packages/astro/components/Picture.astro3
2 files changed, 7 insertions, 1 deletions
diff --git a/.changeset/quiet-games-film.md b/.changeset/quiet-games-film.md
new file mode 100644
index 000000000..bb9584d36
--- /dev/null
+++ b/.changeset/quiet-games-film.md
@@ -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.
diff --git a/packages/astro/components/Picture.astro b/packages/astro/components/Picture.astro
index d4327840a..b0791f163 100644
--- a/packages/astro/components/Picture.astro
+++ b/packages/astro/components/Picture.astro
@@ -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;