Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: responsive images on item page #635

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions apps/web/components/Gallery/Gallery.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
fit="fill"
class="object-contain h-full w-full"
:quality="80"
:src="productImageGetters.getImageUrl(image)"
sizes="2xs:100vw, md:700px"
:srcset="getSourceSet(image)"
sizes="2xs:370px xs:720px sm:740px md:1400px"
draggable="false"
:loading="index === 0 ? 'eager' : 'lazy'"
:fetchpriority="index === 0 ? 'high' : 'auto'"
Expand Down Expand Up @@ -138,6 +138,20 @@ const lastVisibleThumbnailIntersected = ref(true);
const activeIndex = ref(0);
const imagesLoaded = ref([] as unknown as { [key: string]: boolean });

const getSourceSet = (image: ImagesData) => {
const dpr = 2;
const secondPreview = productImageGetters.getImageUrlSecondPreview(image);
const preview = productImageGetters.getImageUrlPreview(image);
const middle = productImageGetters.getImageUrlMiddle(image);
const full = productImageGetters.getImageUrl(image);

return `
${secondPreview} ${370 * dpr}w,
${preview} ${700 * dpr}w,
${middle} ${720 * dpr}w,
${full} ${1400 * dpr}w
`;
};
onMounted(() => {
nextTick(() => {
for (const [index] of props.images.entries()) {
Expand Down
1 change: 1 addition & 0 deletions docs/changelog/changelog_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@

### 🩹 Fixed

- Item image now loads image url based on format and viewport
- Shop logo is now preloaded.
- Fixed the REST call to fetch the remote configuration in the build process.
- Fixed: middleware calls being stuck in an infinite loop
Expand Down
Loading