-
Notifications
You must be signed in to change notification settings - Fork 107
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
Incorporate layout constraints from ancestor blocks into the sizes calculations #1511
Comments
@mukeshpanchal27 and I have been exploring this issue over the last several weeks and I wanted to give a quick progress update. Technical discoveryIn order to incorporate layout information from column, group, row, and stack blocks that are ancestors of images, we considered several different approaches. Use
|
To help with implementation of this issue, I'm listing some use cases we need to solve for
|
@mukeshpanchal27 before we get to far into this, I think trying to reorganize the file structure of the plugin a bit to separate the auto-sizes feature from the functionality to improve sizes calculation could be heplful. I've taked a pass at doing so in #1699. |
@joemcgill Here is different use cases for column block.
|
Thanks @mukeshpanchal27. This is a good list of ways of creating columns in different layouts. For the purposes of defining the requirements for the the "Use block context to pass layout info from columns:" use case listed here, I think we should focus on what the expected For example: Each column block that doesn't contain a <!-- wp:columns -->
<div class="wp-block-columns"><!-- wp:column -->
<div class="wp-block-column"><!-- wp:image -->
<figure class="wp-block-image"><img alt=""/></figure>
<!-- /wp:image --></div>
<!-- /wp:column -->
<!-- wp:column -->
<div class="wp-block-column"><!-- wp:image -->
<figure class="wp-block-image"><img alt=""/></figure>
<!-- /wp:image --></div>
<!-- /wp:column --></div>
<!-- /wp:columns --> ...the |
As noted in #1701 (comment), when using layout widths returned by According to this documentation, these values can be any valid CSS length value, including absolute values (e.g., px), relative values (e.g., rem, em, vw), percentages, CSS functions (e.g. For any values that can't be compared directly on the server we'll need to see if we can write $alignment = auto_sizes_get_layout_width( 'default' );
$layout_width = sprintf( '%1$spx', min( (int) $alignment, $image_width ) ); We would want to consider something like this: $alignment = auto_sizes_get_layout_width( 'default' );
$layout_width = "sprintf( 'min(%1$dpx, $alignment)', array( $image_width, $alignment ) ); |
As outlined in #760, the initial work for accurately setting the sizes attribute for image and cover blocks has been released through the Enhanced Responsive Images plugin. While the current implementation effectively handles individual image blocks, it does not account for images constrained by other ancestor blocks. This issue aims to address this issue by focusing on multiple block types, including column, group, row, and stack blocks (alignments only). Enhancements for grid blocks are also being considered (though they are of lower priority due to their complexity and recent introduction).
The primary goal is to improve the sizes attribute across these block types to ensure images are displayed with the correct sizes for optimal rendering across different screen sizes.
The text was updated successfully, but these errors were encountered: