-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remote srcset images not being resized and deduplication not wor…
…king in certain cases (#8823) * fix: remote `srcset` images not being resized * fix: hash keys ordered to reduce duplicate assets * fix: move to workaround for hashing function * fix: rework transform logic for densities and widths * chore: changeset * test: add tests * fix: forced base srcset when using widths * fix: unnecessary coalescing * refactor: adjust with feedback --------- Co-authored-by: Matteo Manfredi <matteo@manfredi.io>
- Loading branch information
1 parent
b405b03
commit 8946f2a
Showing
9 changed files
with
213 additions
and
65 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
Fix duplicate images being created in some cases when using densities and/or widths |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'astro': patch | ||
--- | ||
|
||
fix remote srcset images not being resized |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
packages/astro/test/fixtures/core-image/src/pages/srcset.astro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
--- | ||
import { Image } from "astro:assets"; | ||
import image from "../assets/penguin2.jpg"; | ||
--- | ||
|
||
<div id="local-3-images"> | ||
<!-- | ||
In this example, only three images should be generated : | ||
- The base image | ||
- The 1.5x image | ||
- The 2x image | ||
--> | ||
<Image src={image} width={image.width / 2} densities={[1.5, 2]} alt="" /> | ||
</div> | ||
|
||
<div id="remote-3-images"> | ||
<!-- | ||
In this example, only three images should be generated : | ||
- The base image | ||
- The 1.5x image | ||
- The 2x image | ||
--> | ||
<Image src={"https://avatars.githubusercontent.com/u/622227?s=64"} width={32} height={32} densities={[1.5, 2]} alt="" /> | ||
</div> | ||
|
||
<div id="local-1x"> | ||
<!-- | ||
In this example, only one image should be generated : | ||
- The base image, 1x density should be the same as the base image | ||
--> | ||
<Image src={image} width={image.width / 2} densities={[1]} alt="" /> | ||
</div> | ||
|
||
<div id="remote-1x"> | ||
<!-- | ||
In this example, only one image should be generated : | ||
- The base image, 1x density should be the same as the base image | ||
--> | ||
<Image src={"https://avatars.githubusercontent.com/u/622227?s=64"} width={32} height={32} densities={[1]} alt="" /> | ||
</div> | ||
|
||
<div id="local-2-widths"> | ||
<!-- | ||
In this example, only two images should be generated : | ||
- The base image | ||
- The 2x image | ||
--> | ||
<Image src={image} width={image.width / 2} widths={[image.width]} alt="" /> | ||
</div> | ||
|
||
<div id="remote-2-widths"> | ||
<!-- | ||
In this example, only two images should be generated : | ||
- The base image | ||
- The 2x image | ||
--> | ||
<Image src={"https://avatars.githubusercontent.com/u/622227?s=64"} width={32} height={32} widths={[64]} alt="" /> | ||
</div> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.