You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Initial implementation of improved image sizes algorithm #1187
This issue cover adding the first set of enhancement to the auto-sizes plugin, that improve the default image sizes algorithm by constraining the maximum sizes width by layout settings from theme.json and the content width setting in classic themes for default aligned images.
Approach
To kick off this effort, I’ve created a proof of concept implementation, which adds the sizes attribute to images in blocks during the block rendering process, via block render filters. This approach is based on the following initial proposal for new algorithms based on alignment values:
changed the title [-]Create initial plugin version release that constrains the maximum sizes width by layout settings from `theme.json` and the content width setting in classic themes for default aligned images.[/-][+]Initial implementation of improved image `sizes` algorithm[/+]on Apr 29, 2024
While talking through the initial implementation with @mukeshpanchal27 we identified that one of the challenges to this initial implementation is parsing the padding settings from theme.json to use in the proposed improved algorithms suggested in the description above.
That's because many times the theme.json settings for padding reference presets via CSS variables, ex:
Since sizes are parsed before CSS has loaded, we'll need to solve how to parse theme.json paddings into real values. For now, we can simplify our initial implementation to only consider alignment widths:
@joemcgill, while working on the left/right alignment, I noticed that if the image is smaller than the content or wide size, it returns the wrong size. In such cases, we need to return the smaller value among the image width, content size, or wide size.
The different widths used in theme.json for content and wide size are:
620px
min(640px, 90vw)
90vw
How do we get the actual width from the last two width options?
@westonruter, not missed, just not implemented in this first PR. We wanted to get the basic API in place using the theme.json values and then will expand it to include classic theme support.
Activity
[-]Create initial plugin version release that constrains the maximum sizes width by layout settings from `theme.json` and the content width setting in classic themes for default aligned images.[/-][+]Initial implementation of improved image `sizes` algorithm[/+]joemcgill commentedon May 23, 2024
While talking through the initial implementation with @mukeshpanchal27 we identified that one of the challenges to this initial implementation is parsing the padding settings from theme.json to use in the proposed improved algorithms suggested in the description above.
That's because many times the theme.json settings for padding reference presets via CSS variables, ex:
Since
sizesare parsed before CSS has loaded, we'll need to solve how to parse theme.json paddings into real values. For now, we can simplify our initial implementation to only consider alignment widths:(max-width: contentSize) 100vw, contentSize(max-width: wideSize ) 100vw, widesize100vwmukeshpanchal27 commentedon May 27, 2024
@joemcgill, while working on the left/right alignment, I noticed that if the image is smaller than the content or wide size, it returns the wrong size. In such cases, we need to return the smaller value among the image width, content size, or wide size.
The different widths used in
theme.jsonfor content and wide size are:How do we get the actual width from the last two width options?
mukeshpanchal27 commentedon Jun 5, 2024
@joemcgill Do we needs to close this issue as initial implementation PR merged.
joemcgill commentedon Jun 11, 2024
Sure can!
westonruter commentedon Jun 25, 2024
I just noticed that #1250 doesn't implement support for
$content_widthglobal in classic themes. Was that missed?joemcgill commentedon Jun 25, 2024
@westonruter, not missed, just not implemented in this first PR. We wanted to get the basic API in place using the theme.json values and then will expand it to include classic theme support.