-
Notifications
You must be signed in to change notification settings - Fork 98
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
Parse width presets for use in sizes
values
#1251
Comments
For initial work:
cc. @joemcgill |
Thanks for raising this issue, @mukeshpanchal27. As I've been reviewing #1252, I noticed that even when a smaller image is used, WP includes the following default CSS that will make a smaller image stretch to the wide and full alignment container, regardless of its intrinsic width: .wp-block-image.alignfull img,.wp-block-image.alignwide img{
height:auto;
width:100%;
} Usually, WordPress should be using the wide or full alignment size to populate the The only use cases where the sizes improvements in our plugin should respect a smaller intrinsic width of the image is when it is using default, center, left, or right alignments. For wide and full alignments, the images get stretched to fill the width of the container, so our plugin should update the sizes attribute to use the layout width instead. The same use cases apply when an image is manually resized in the editor. However, in those cases, the image block controls the layout width by applying an inline style attribute, like Another thing I realized while reviewing your PR is that we should be able to use the image width that is already added to the image, rather than needing to call Summarizing next steps
|
@joemcgill If we use |
True. those block attributes get rendered as CSS classes on the One way that I can see to do that is to filter the class WPP_Block_Parser extends WP_Block_Parser {
private static $attachment_ids;
public function parse( $document ) {
// parse the blocks.
$blocks = parent::parse()
// Loop through blocks to get all of the attachment IDs.
foreach ( $blocks as $block ) {
// Look for ID and add to the $attachment_ids array.
}
_prime_post_caches( self::$attachment_ids, false, true );
return $blocks;
}
} This would probably be much easier to do if Alternately, we could add the alignment to the |
Marking this as fixed by #1252. |
As described in #1187 (comment), If the image is smaller than the content or wide size, it returns the wrong (bigger) 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.
We should parse the width so we can use proper width in sizes to get proper image size.
The text was updated successfully, but these errors were encountered: