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

Added page width setting and fixed image quality #292

Merged
merged 7 commits into from
Aug 4, 2021

Conversation

tyleralsbury
Copy link
Contributor

@tyleralsbury tyleralsbury commented Jul 29, 2021

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.

Screen Shot 2021-07-29 at 4 15 07 PM

Screen Shot 2021-07-29 at 4 15 02 PM

Demo links

Checklist

Copy link
Contributor

@martinamarien martinamarien left a 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.

config/settings_schema.json Outdated Show resolved Hide resolved
locales/en.default.schema.json Outdated Show resolved Hide resolved
@@ -181,7 +181,7 @@ html.no-js .no-js-hidden {
}

.page-width-desktop {
max-width: 160rem;
max-width: var(--page-width);
Copy link
Contributor

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?

Copy link
Contributor Author

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?

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. 👍

sections/collage.liquid Outdated Show resolved Hide resolved
sections/collage.liquid Outdated Show resolved Hide resolved
sections/collage.liquid Outdated Show resolved Hide resolved
sections/collection-list.liquid Outdated Show resolved Hide resolved
{% 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)"
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@gretchen-willenberg
Copy link
Contributor

Back from break with some belated copy feedback:

  1. Would spell out maximum to benefit translation and accessibility: Maximum page width
  2. Is px included with 1200 and 1600? 1200px and 1600px without spaces is correct.
  3. For consistency and future growth, would Pages be a subhead to give more information on what the layout is applied to vs just the settings label? If Layout was like Typography, etc:
    Layout
    Pages
    Maximum page width

Screen Shot 2021-08-02 at 11 23 02 AM

Copy link
Contributor

@tauthomas01 tauthomas01 left a 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/image-with-text.liquid Outdated Show resolved Hide resolved
{%- 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 -%}"
Copy link
Contributor

@tauthomas01 tauthomas01 Aug 2, 2021

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.

image

Copy link
Contributor Author

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).

sections/main-search.liquid Outdated Show resolved Hide resolved
{%- 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 -%}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm curious about this one as well. The max width an image can take is 1500px and on high end laptop, the density pixel ratio is 2x, so 1500 x 2 = 3000 so I'm wondering if the 3840px is needed.

image

I am not sure if it makes sense.

Copy link
Contributor Author

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.

@martinamarien
Copy link
Contributor

For consistency and future growth, would Pages be a subhead to give more information on what the layout is applied to vs just the settings label? If Layout was like Typography, etc:
Layout
Pages
Maximum page width

@gretchen-willenberg Since Pages is a type of template, is there any concern that merchants might think this setting would only apply to the Pages template type if we use the Pages subheading?

Screen Shot 2021-08-03 at 9 11 42 AM

@wiktoriaswiecicka-zz
Copy link

wiktoriaswiecicka-zz commented Aug 3, 2021

For consistency and future growth, would Pages be a subhead to give more information on what the layout is applied to vs just the settings label? If Layout was like Typography, etc:
Layout
Pages
Maximum page width

@gretchen-willenberg Since Pages is a type of template, is there any concern that merchants might think this setting would only apply to the Pages template type if we use the Pages subheading?

I agree, that using Maximum page width as a label may sound confusing. I'd be in favour of keeping Maximum width, or maybe Maximum grid width?

@gretchen-willenberg
Copy link
Contributor

I agree, that using Maximum page width as a label may sound confusing. I'd be in favour of keeping Maximum width, or maybe Maximum grid width?

+100 @martinamarien and @wiktoriaswiecicka

  1. If layout needed a subheading for context it would have to be something more inclusive to reflect all templates and pages, like online store pages Since it's Theme settings > layout we likely don't need unless or until we add any other layout settings.
  2. Agree with label of maximum width. Using grid might be too inside-design and a bit of a learning curve for merchants that we may not need to put on them.

@tyleralsbury
Copy link
Contributor Author

Made some adjustments based on the comments + discussions. Let me know if this is good for the content or if we want to make further changes:

Screen Shot 2021-08-03 at 11 53 40 AM

@gretchen-willenberg
Copy link
Contributor

Thank you, @tyleralsbury! Please delete the Pages subheading.

Sorry for the confusion.

@tyleralsbury
Copy link
Contributor Author

No problemo. Removed it.

Copy link
Contributor

@tauthomas01 tauthomas01 left a 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.

sections/main-search.liquid Outdated Show resolved Hide resolved
sections/main-search.liquid Outdated Show resolved Hide resolved
@tyleralsbury
Copy link
Contributor Author

Fixed them, @tauthomas01 - good catch. It was hard to find all of those.

tauthomas01
tauthomas01 previously approved these changes Aug 3, 2021
Copy link
Contributor

@tauthomas01 tauthomas01 left a 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 -%}"
Copy link
Contributor

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.

Copy link
Contributor Author

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.

martinamarien
martinamarien previously approved these changes Aug 4, 2021
Copy link
Contributor

@martinamarien martinamarien left a 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' }}"
Copy link
Contributor

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

Copy link
Contributor Author

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.

@tyleralsbury tyleralsbury merged commit 9070ef0 into main Aug 4, 2021
@tyleralsbury tyleralsbury deleted the page-width-setting branch August 4, 2021 20:20
@gregjotau
Copy link

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 😅

https://github.com/gregjotau/dawn-famme
famme.no

@gregjotau
Copy link

But might need we need to reupload and adjust our images based on these changes? 🤔

@martinamarien
Copy link
Contributor

but I immediately think that merging this change into our theme made it look worse 😅

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.

olafghanizadeh pushed a commit to hyttefeber/dawn that referenced this pull request Aug 5, 2021
* Added page width setting and fixed image quality
@gregjotau
Copy link

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 🙌

maplerock added a commit to fellowsmedia/nsra_shopify_2021 that referenced this pull request Aug 12, 2021
* 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)
  ...
phapsidesGT pushed a commit to Gravytrain-UK/gt-shopify-dawn-theme that referenced this pull request Sep 3, 2024
* Added page width setting and fixed image quality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Theme setting to set page width (regular vs wide) Improve photo quality
6 participants