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

First batch of images picture tag #377

Merged
merged 16 commits into from
Dec 7, 2022
Merged

Conversation

NeOMakinG
Copy link
Contributor

@NeOMakinG NeOMakinG commented Oct 17, 2022

Questions Answers
Description? We wants to switch images to picture tags and support webp and avif for 8.1
Type? improvement
BC breaks? no
Deprecations? no
How to test? Images should work as expected, double density screens should receive 2x sizes
Possible impacts? Images

Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

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

Quick check

templates/catalog/_partials/miniatures/product.tpl Outdated Show resolved Hide resolved
templates/catalog/_partials/miniatures/product.tpl Outdated Show resolved Hide resolved
templates/catalog/_partials/miniatures/product.tpl Outdated Show resolved Hide resolved
templates/catalog/_partials/product-cover-thumbnails.tpl Outdated Show resolved Hide resolved
templates/catalog/_partials/product-cover-thumbnails.tpl Outdated Show resolved Hide resolved
templates/checkout/_partials/cart-summary-product-line.tpl Outdated Show resolved Hide resolved
templates/cms/stores.tpl Outdated Show resolved Hide resolved
templates/catalog/_partials/product-cover-thumbnails.tpl Outdated Show resolved Hide resolved
src="{$image.bySize.default_720.sources.jpg}"
width="{$image.bySize.default_720.width}"
height="{$image.bySize.default_720.height}"
loading="lazy"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to use loading="eager" on the first image. It will be FCP element that we need to load ASAP. It would maybe be also good to add a preload element to header so it starts loading right away.

Something like:

<link rel="preload" as="image"
  imagesrcset="{$product.cover.bySize.medium_default.url} 452w,
  {$product.cover.bySize.pdt_180.url} 180w,
  {$product.cover.bySize.pdt_300.url} 300w,
  {$product.cover.bySize.pdt_360.url} 360w,
  {$product.cover.bySize.pdt_540.url} 540w,
  {$product.cover.bySize.pdt_590.url} 590w"
  imagesizes="(min-width: 1300px) 590px, (min-width: 768px) 50vw, 100vw"
  href="{$product.cover.bySize.medium_default.url}">

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Leaving the comment opened for the preload if we want to implement it

config/theme.yml Show resolved Hide resolved
config/theme.yml Show resolved Hide resolved
@SharakPL
Copy link
Contributor

SharakPL commented Oct 26, 2022

I'm not sure this is the right way. IMO names should be specific to the target: product_main, product_zoom, product_miniature, product_cart, category_main for the baner on category page, category_miniature, etc. and all responsive versions should be generated automatically, with widths configured in theme's configuration module. Naming should be common for all themes, not just for this one. The same for responsive versions: _xs, not _320

@Hlavtox
Copy link
Contributor

Hlavtox commented Oct 26, 2022

@SharakPL Well, the point is, that the images are usable on multiple places sometime.

Our notes are something like this:

Product
- 120x120 px for thumbnails
- 200x200 for mobile listing
- 320x320 for desktop listing
- 400x400 for mobile listing 2x
- 720x720 for product detail
- 1440x1440 for 2x product detail
Category thumbnail (subcategories)
- 80x80
- 160x160 for 2x
- 320x320 for 3x
Category cover
- 1000x1000
- 2000x2000 for 2x
Manufacturer - used on product page and in manufacturer listing
- 100x100
- 200x200 for 2x
Suppliers
- 100x100
- 200x200 for 2x
Stores
- 200x200
- 400x400 for 2x

@SharakPL
Copy link
Contributor

SharakPL commented Oct 26, 2022

Of course some common sizes could be kept eg. default_100 or default_200. I doubt they'll ever change in any theme, But what if I want to use 450x600 image for product miniature (main product image would be eg. 750x1000) and 350x150 on category miniature? It can't be done here because they all use default_320. Even if I wanted to use the same size for both, but eg. 400x400 it would still have to be named default_320 because that's what the theme uses in the templates. That's why we should change naming convention for the thumbs.

Category cover

  • 1000x1000
  • 2000x2000 for 2x

And what's with these huge category covers? It's supposed to be wide banner, not huge square covering whole screen #49

@NeOMakinG
Copy link
Contributor Author

@Hlavtox I guess @SharakPL is right, we should name it differently so if someone change the size, he won't need to use a default_200 name if it's now 300

@NeOMakinG
Copy link
Contributor Author

NeOMakinG commented Oct 26, 2022

If anyone from the maintainer/committer team wants to commit something or work on that naming, feel free, otherwise I'll do it later

@Hlavtox
Copy link
Contributor

Hlavtox commented Oct 26, 2022

Yeah I would also do some sensible names. ;-)

config/theme.yml Outdated Show resolved Hide resolved
templates/catalog/_partials/product-cover-thumbnails.tpl Outdated Show resolved Hide resolved
config/theme.yml Show resolved Hide resolved
templates/catalog/_partials/miniatures/product.tpl Outdated Show resolved Hide resolved
@NeOMakinG NeOMakinG changed the title [POC] Images picture tag Images picture tag Dec 6, 2022
@NeOMakinG NeOMakinG marked this pull request as ready for review December 6, 2022 14:19
@NeOMakinG NeOMakinG changed the title Images picture tag First batch of images picture tag Dec 6, 2022
Copy link
Contributor

@Hlavtox Hlavtox left a comment

Choose a reason for hiding this comment

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

Looks good! Let's get this merged!

@NeOMakinG NeOMakinG dismissed SharakPL’s stale review December 7, 2022 09:10

Every changes have been addresses

@Hlavtox Hlavtox merged commit 47d0ad5 into PrestaShop:develop Dec 7, 2022
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.

3 participants