-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Added page width setting and fixed image quality #292
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't get a chance yet to review the actual image size changes. I will do this tomorrow if you don't already have two reviewers.
@@ -181,7 +181,7 @@ html.no-js .no-js-hidden { | |||
} | |||
|
|||
.page-width-desktop { | |||
max-width: 160rem; | |||
max-width: var(--page-width); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Should the page-width--narrow
be adjusted based on which page with a merchant selects?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question - @wiktoriaswiecicka do you think it should be something like a percentage of the selected value? Looks like it was a kinda strange width of 726px before. If we made it 72rem
, that'd be 60%. So maybe we could make it so that it's 60% of the width of the page-width
.
Then when it's 1200px, it'll be 720px for --narrow
and when it's 1600px, it'll be 960px for the --narrow
. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree - the percentage value (60%) makes sense. 👍
{% if media.preview_image.width >= 1100 %}{{ media.preview_image | img_url: '1100x' }} 1100w,{% endif %} | ||
{% if media.preview_image.width >= 1500 %}{{ media.preview_image | img_url: '1500x' }} 1500w{% endif %}" | ||
src="{{ media | img_url: '1500x' }}" | ||
sizes="(min-width: {{ settings.page_width }}px) {{ settings.page_width | minus: 100 | times: 0.64 | round }}px, (min-width: 750px) calc((100vw - 11.5rem) / 2), calc(100vw - 4rem)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you explain why you chose 0.64?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep - the width of the product page media wrapper is 64%, so this allows a slightly more accurate calculation of how big the image should be.
Back from break with some belated copy feedback:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I looked at the image rendering and the network tab, images size look adequate.
I left some small comments.
Let me know if you have any questions
sections/main-search.liquid
Outdated
{%- if item.image.src.width >= 940 -%}{{ item.image.src | img_url: '940x' }} 714w{%- endif -%}" | ||
src="{{ item.image.src | img_url: '533x' }}" | ||
{%- if item.image.src.width >= 940 -%}{{ item.image.src | img_url: '940x' }} 714w{%- endif -%} | ||
{%- if item.image.src.width >= 1066 -%}{{ item.image.src | img_url: '1066x' }} 1066w{%- endif -%}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious where does 1066
comes from but also this template.
Because the grid will always be set at 4 columns, one grid item measures 264px. If we want the high resolution size (like high density display, which I believe is 2x
, or 3x
of density pixel ratio if it's iPhone X or high-end phone), it would be 264 * 3 = 792px.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 1066
comes from a 3x at 749px
. Rather than base it on devices, which change over time, I've based it on the actual breakpoints. The images are 355, so 355 * 3 = 1065 (not 1066, so that was my bad).
{%- if section.settings.cover_image.width >= 1780 -%}{{ section.settings.cover_image | img_url: '1780x' }} 1780w,{%- endif -%} | ||
{%- if section.settings.cover_image.width >= 2000 -%}{{ section.settings.cover_image | img_url: '2000x' }} 2000w,{%- endif -%} | ||
{%- if section.settings.cover_image.width >= 3000 -%}{{ section.settings.cover_image | img_url: '3000x' }} 3000w,{%- endif -%} | ||
{%- if section.settings.cover_image.width >= 3840 -%}{{ section.settings.cover_image | img_url: '3840x' }} 3840w,{%- endif -%}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the video section can go full width, I've included 3840 to account for 4k screens. I was going to also include 7680, but I don't think there are 2x pixel density 4k screens.
@gretchen-willenberg Since |
I agree, that using |
+100 @martinamarien and @wiktoriaswiecicka
|
Thank you, @tyleralsbury! Please delete the Sorry for the confusion. |
No problemo. Removed it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks good on my end. We just need to fix this small typo.
Fixed them, @tauthomas01 - good catch. It was hard to find all of those. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
{%- if block.settings.cover_image.width >= 1100 -%}{{ block.settings.cover_image | img_url: '1100x' }} 1100w,{%- endif -%} | ||
{%- if block.settings.cover_image.width >= 1500 -%}{{ block.settings.cover_image | img_url: '1500x' }} 1500w,{%- endif -%} | ||
{%- if block.settings.cover_image.width >= 2200 -%}{{ block.settings.cover_image | img_url: '2200x' }} 2200w,{%- endif -%} | ||
{%- if block.settings.cover_image.width >= 3000 -%}{{ block.settings.cover_image | img_url: '3000x' }} 3000w,{%- endif -%}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In some of the srcset
values, you're ending with a ,
. I think we can remove it in the last if block - there are a few files that this is happening in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that causes any issues with the srcset
working properly.
I kinda bounced between the two the past few times I looked at srcset
and I actually think the trailing comma is better because if someone wants to add another element to the end of it, they can, whereas if the comma's not there they would need to notice that the comma is missing, add it, and then add their line.
So if anything, I think they should have the comma. I'm not sure if we should worry too much about it now, though. We can smooth out rough edges like this in the coming weeks as we tackle some of the lower priority fixes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested all the use cases and it looks good.
Just one question for you about a src size
{%- if collection.image.width >= 535 -%}{{ collection.image | img_url: '535x' }} 535w,{%- endif -%} | ||
{%- if collection.image.width >= 750 -%}{{ collection.image | img_url: '750x' }} 750w,{%- endif -%} | ||
{%- if collection.image.width >= 1070 -%}{{ collection.image | img_url: '1070x' }} 1070w,{%- endif -%} | ||
{%- if collection.image.width >= 1500 -%}{{ collection.image | img_url: '1500x' }} 1500w,{%- endif -%}" | ||
src="{{ collection.image | img_url: '533x' }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Why '533x'? In the other images, it looks like src is using a value represented by the srcset
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good question. I missed that one. I've been trying to represent the largest 1x size for the most part since I'm assuming anyone using a browser that doesn't support srcset
is unlikely to be on any sort of fancy high pixel density screen. I'll fix it up.
1fb480e
It might be because of changes we have on our theme, but I immediately think that merging this change into our theme made it look worse 😅 |
But might need we need to reupload and adjust our images based on these changes? 🤔 |
Do you mean the page width setting or the changes to the image sizes/srcset? If it's the page width setting, you can choose to change the setting to 1200, which is what dawn's previous width was by default. |
* Added page width setting and fixed image quality
It might be the changes to the sizes which made it a bit weird on larger screens (24"), but it does not matter much since everyone browses on mobile. We do have some customization for mobile photo upload in the image banner liquid, so might be that we have screwed up something as well 😓 Will have to do a diff to verify. A built in mobile image upload would be awesome so we can remove our customization 🙌 |
* main: (23 commits) Cart content update (Shopify#370) Footer spacing and alignment adjustments (Shopify#369) Product Template UI polish updates (Shopify#219) footer ui updates (Shopify#318) Fix cart improvements empty state (Shopify#319) [Announcement] Adjust block id for displaying dynamic names (Shopify#327) Update translations: buyer (Shopify#329) Revert editor setting changes (Shopify#328) Update translations (Shopify#294) Fix collection filtering UX (Shopify#268) Added page width setting and fixed image quality (Shopify#292) Add top border on cart notification when "show separator line" setting is deactivated (Shopify#306) movebadge code into base.css (Shopify#313) Collage UI bug fixes (Shopify#308) Customer account UI polish (Shopify#177) Added custom liquid block to product page (Shopify#269) Fix disclosure icon (Shopify#310) Fix facet price filter label spacing (Shopify#300) Fix duplicate search icon when header logo is set to "Top center" (Shopify#252) Add card outline setting (Shopify#239) ...
* Added page width setting and fixed image quality
Why are these changes introduced?
Fixes #289
Fixes #291
What approach did you take?
I've added a setting in the schema and updated the srcset/sizes properties for the images throughout the theme to output the right quality images for each setting.
Other considerations
Might need a content pass from @melissaperreault and @gretchen-willenberg - I put in what I thought made sense, but there may be a better way of phrasing things. Also note the position within the theme settings menu which can be changed if it's not in a great spot.
Currently there are two options - 1600px and 1200px, but we could technically add more or use a range. I implemented it in a way that allows for either approach.
Demo links
Checklist