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

Image block: unwrap img element in editor #68666

Merged
merged 3 commits into from
Feb 28, 2025
Merged

Conversation

stokesman
Copy link
Contributor

@stokesman stokesman commented Jan 14, 2025

What?

An attempt to fix several issues with the Image block in the editor by:

  • Making the editor markup more similar to the front end (removes div wrapper around img).
  • Omitting size controls of Image block when inside flex layouts.
    I don’t think there’s as strong a reason to do this but I tried it because the size controls seem likely to be confusing in flex layouts.

There is also a few minor changes related to code quality.

Why?

Most generally this seems like a good idea because the markup becomes more similar to that of the front end.

How?

  1. Removes wrapping divs from the img in the editor markup.
    • The ResizableBox component is made a sibling (instead of a parent).
    • Removes the wrapping div that was there when not resizable.
  2. Adds logic/state to ensure overlaid placement of the ResizableBox on the img.
    • a mount effect on ResizableBox
    • resize observation on the img
  3. In flex layouts, omits the ResizableBox and width/height inspector controls.

Testing Instructions

  • Follow the reproduction steps for the linked issues and verify that you cannot reproduce them
  • Test everything you can think of having to do with the Image block
Markup I used in testing these issues. You’ll have to replace the images with your own though.
<!-- wp:paragraph -->
<p>The following are editor specific bugs or incongruities as compared to the front end.</p>
<!-- /wp:paragraph -->

<!-- wp:heading {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="padding-top:var(--wp--preset--spacing--20)">⛔️ Resize handle placement is incorrect for an non-resized image whose natural width is less than the theme’s content width</h2>
<!-- /wp:heading -->

<!-- wp:image {"id":19,"sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="http://localhost:8888/wp-content/uploads/2024/05/pine-flower.webp" alt="" class="wp-image-19"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20"},"margin":{"top":"40vh"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="margin-top:40vh;padding-top:var(--wp--preset--spacing--20)">⛔️ Width stretched to content width for an non-resized image whose natural width is less than the theme’s content width when aspect ratio is specified</h2>
<!-- /wp:heading -->

<!-- wp:image {"id":19,"aspectRatio":"16/9","scale":"cover","sizeSlug":"full","linkDestination":"none"} -->
<figure class="wp-block-image size-full"><img src="http://localhost:8888/wp-content/uploads/2024/05/pine-flower.webp" alt="" class="wp-image-19" style="aspect-ratio:16/9;object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:heading {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20"},"margin":{"top":"40vh"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="margin-top:40vh;padding-top:var(--wp--preset--spacing--20)">⛔️ Wrong size in flex and grid layouts</h2>
<!-- /wp:heading -->

<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:image {"id":135,"width":"130px","height":"auto","scale":"cover","sizeSlug":"full","linkDestination":"none","style":{"layout":{"selfStretch":"fit","flexSize":null}}} -->
<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2024/07/image.jpeg" alt="" class="wp-image-135" style="object-fit:cover;width:130px;height:auto"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph {"style":{"layout":{"selfStretch":"fit","flexSize":null}}} -->
<p>In a row block, if an image is resized to a specific width and placed next to a potentially wide block like a multi-lined paragraph, it maintains its specified size yet the appears small on the front end. This breaks WYSIWYG expectations.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:group {"layout":{"type":"grid","columnCount":3,"rowCount":2,"isManualPlacement":true,"minimumColumnWidth":null}} -->
<div class="wp-block-group"><!-- wp:image {"id":19,"width":"504px","height":"auto","sizeSlug":"full","linkDestination":"none","style":{"layout":{"columnStart":1,"rowStart":1,"rowSpan":2}}} -->
<figure class="wp-block-image size-full is-resized"><img src="http://localhost:8888/wp-content/uploads/2024/05/pine-flower.webp" alt="" class="wp-image-19" style="width:504px;height:auto"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph {"style":{"color":{"background":"#ffffffa8"},"layout":{"columnStart":2,"rowStart":1}},"fontSize":"medium"} -->
<p class="has-background has-medium-font-size" style="background-color:#ffffffa8">In a grid block, it’s a similar situation.</p>
<!-- /wp:paragraph -->

<!-- wp:paragraph {"style":{"color":{"background":"#ffffffa8"},"layout":{"columnStart":3,"rowStart":1}},"fontSize":"medium"} -->
<p class="has-background has-medium-font-size" style="background-color:#ffffffa8">Another sibling.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:heading {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20"},"margin":{"top":"40vh"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="margin-top:40vh;padding-top:var(--wp--preset--spacing--20)">⛔️ If the image is shorter than the line-height so too is the figure and vertical alignment is incongruent with the front end</h2>
<!-- /wp:heading -->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"color":{"background":"#f3d5f1"}},"fontSize":"xx-large","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-background has-xx-large-font-size" style="background-color:#f3d5f1;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:image {"id":63,"width":"32px","sizeSlug":"full","linkDestination":"none","style":{"spacing":{"margin":{"left":"var:preset|spacing|20","right":"0"}}}} -->
<figure class="wp-block-image size-full is-resized" style="margin-right:0;margin-left:var(--wp--preset--spacing--20)"><img src="http://localhost:8888/wp-content/uploads/2024/06/transparent-site-icon.png" alt="" class="wp-image-63" style="width:32px"/></figure>
<!-- /wp:image --></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|40","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"typography":{"letterSpacing":"21px"},"color":{"background":"#f3d5f1"}},"fontSize":"xx-large","layout":{"type":"constrained","justifyContent":"center"}} -->
<div class="wp-block-group has-background has-xx-large-font-size" style="background-color:#f3d5f1;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--20);letter-spacing:21px"><!-- wp:image {"id":63,"width":"32px","height":"auto","sizeSlug":"full","linkDestination":"none","align":"left","style":{"spacing":{"margin":{"left":"var:preset|spacing|20","right":"var:preset|spacing|20"}}}} -->
<figure class="wp-block-image alignleft size-full is-resized" style="margin-right:var(--wp--preset--spacing--20);margin-left:var(--wp--preset--spacing--20)"><img src="http://localhost:8888/wp-content/uploads/2024/06/transparent-site-icon.png" alt="" class="wp-image-63" style="width:32px;height:auto" title="fub"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>SOMETHING</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:heading {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20"},"margin":{"top":"50vh"}}},"fontSize":"large"} -->
<h2 class="wp-block-heading has-large-font-size" style="margin-top:50vh;padding-top:var(--wp--preset--spacing--20)">⛔️ Image may disappear when cropping/rotating in flex layouts</h2>
<!-- /wp:heading -->

<!-- wp:group {"layout":{"type":"flex","flexWrap":"nowrap"}} -->
<div class="wp-block-group"><!-- wp:image {"id":74,"scale":"cover","sizeSlug":"full","linkDestination":"none","style":{"layout":{"selfStretch":"fit","flexSize":null}}} -->
<figure class="wp-block-image size-full"><img src="http://localhost:8888/wp-content/uploads/2024/06/Example-Background-Image.jpg" alt="" class="wp-image-74" style="object-fit:cover"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>It happens if the image lacks a specified size and even without other siblings in the row.</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

Screenshots or screencast

Editor/Front-end incongruities

Wrong size in flex and grid layouts (#68057 is open for this but is Row specific)

Before Front end After
image-block-size-in-grid-flex-before image-block-size-in-grid-flex-front image-block-size-in-grid-flex-after

Image incorrectly filling the content-width #52219

An image block with an image that is smaller than the width of the post container with a specified aspect ratio and no specified size is incorrectly filling the width of the container.

Before Front end After
image-block-stretch-w-aspect-ratio-before image-block-stretch-w-aspect-ratio-front image-block-stretch-w-aspect-ratio-after

Layout incorrect for images that are shorter than line-height (no open issue, I think)

If the image is shorter than the line-height so too is the figure and vertical alignment is incongruent with the front end

Before Front end After
image-block-short-before image-block-short-front image-block-short-after

Editor-only issues

Resize handles out of place (I think there’s no open issue)

It affects images that are narrower than the content width with no size specified.

Before After
image-block-resize-handle-before image-block-resize-handle-after

Disappearing image when editing (crop/rotate) auto-sized images inside flex layouts #68668

image-disappears-when-edited-in-flex.mp4

Layout shifts when editing (crop/rotate) auto-sized images

In trunk, an image without any specified size doesn’t maintain its displayed size when cropping/rotating. In this branch the image size will be maintained. This is an incidental change but might be hard to separate from the fix for the preceding issue. Besides it seems like a nice thing for consistency with how it works in most other scenarios (no layout shift).

Before After
image-block-crop-unsized-before image-block-crop-unsized-after

@stokesman stokesman added [Type] Bug An existing feature does not function as intended [Block] Image Affects the Image Block labels Jan 14, 2025
Copy link

github-actions bot commented Jan 14, 2025

Size Change: +74 B (0%)

Total Size: 1.84 MB

Filename Size Change
build/block-library/blocks/image/editor-rtl.css 763 B -36 B (-4.51%)
build/block-library/blocks/image/editor.css 763 B -36 B (-4.51%)
build/block-library/editor-rtl.css 11.4 kB -10 B (-0.09%)
build/block-library/editor.css 11.4 kB -11 B (-0.1%)
build/block-library/index.min.js 225 kB +167 B (+0.07%)
ℹ️ View Unchanged
Filename Size
build-module/a11y/index.min.js 482 B
build-module/block-library/file/view.min.js 447 B
build-module/block-library/form/view.min.js 533 B
build-module/block-library/image/view.min.js 1.8 kB
build-module/block-library/navigation/view.min.js 1.18 kB
build-module/block-library/query/view.min.js 767 B
build-module/block-library/search/view.min.js 639 B
build-module/interactivity-router/index.min.js 3.04 kB
build-module/interactivity/debug.min.js 17.5 kB
build-module/interactivity/index.min.js 13.9 kB
build/a11y/index.min.js 952 B
build/annotations/index.min.js 2.26 kB
build/api-fetch/index.min.js 2.4 kB
build/autop/index.min.js 2.12 kB
build/blob/index.min.js 579 B
build/block-directory/index.min.js 7.13 kB
build/block-directory/style-rtl.css 1.03 kB
build/block-directory/style.css 1.03 kB
build/block-editor/content-rtl.css 4.42 kB
build/block-editor/content.css 4.41 kB
build/block-editor/default-editor-styles-rtl.css 394 B
build/block-editor/default-editor-styles.css 394 B
build/block-editor/index.min.js 263 kB
build/block-editor/style-rtl.css 15.9 kB
build/block-editor/style.css 15.9 kB
build/block-library/blocks/archives/editor-rtl.css 84 B
build/block-library/blocks/archives/editor.css 83 B
build/block-library/blocks/archives/style-rtl.css 90 B
build/block-library/blocks/archives/style.css 90 B
build/block-library/blocks/audio/editor-rtl.css 149 B
build/block-library/blocks/audio/editor.css 151 B
build/block-library/blocks/audio/style-rtl.css 132 B
build/block-library/blocks/audio/style.css 132 B
build/block-library/blocks/audio/theme-rtl.css 134 B
build/block-library/blocks/audio/theme.css 134 B
build/block-library/blocks/avatar/editor-rtl.css 115 B
build/block-library/blocks/avatar/editor.css 115 B
build/block-library/blocks/avatar/style-rtl.css 104 B
build/block-library/blocks/avatar/style.css 104 B
build/block-library/blocks/button/editor-rtl.css 265 B
build/block-library/blocks/button/editor.css 265 B
build/block-library/blocks/button/style-rtl.css 555 B
build/block-library/blocks/button/style.css 555 B
build/block-library/blocks/buttons/editor-rtl.css 291 B
build/block-library/blocks/buttons/editor.css 291 B
build/block-library/blocks/buttons/style-rtl.css 345 B
build/block-library/blocks/buttons/style.css 345 B
build/block-library/blocks/calendar/style-rtl.css 240 B
build/block-library/blocks/calendar/style.css 240 B
build/block-library/blocks/categories/editor-rtl.css 132 B
build/block-library/blocks/categories/editor.css 131 B
build/block-library/blocks/categories/style-rtl.css 152 B
build/block-library/blocks/categories/style.css 152 B
build/block-library/blocks/code/editor-rtl.css 53 B
build/block-library/blocks/code/editor.css 53 B
build/block-library/blocks/code/style-rtl.css 139 B
build/block-library/blocks/code/style.css 139 B
build/block-library/blocks/code/theme-rtl.css 122 B
build/block-library/blocks/code/theme.css 122 B
build/block-library/blocks/columns/editor-rtl.css 108 B
build/block-library/blocks/columns/editor.css 108 B
build/block-library/blocks/columns/style-rtl.css 420 B
build/block-library/blocks/columns/style.css 420 B
build/block-library/blocks/comment-author-avatar/editor-rtl.css 124 B
build/block-library/blocks/comment-author-avatar/editor.css 124 B
build/block-library/blocks/comment-author-name/style-rtl.css 72 B
build/block-library/blocks/comment-author-name/style.css 72 B
build/block-library/blocks/comment-content/style-rtl.css 120 B
build/block-library/blocks/comment-content/style.css 120 B
build/block-library/blocks/comment-date/style-rtl.css 65 B
build/block-library/blocks/comment-date/style.css 65 B
build/block-library/blocks/comment-edit-link/style-rtl.css 70 B
build/block-library/blocks/comment-edit-link/style.css 70 B
build/block-library/blocks/comment-reply-link/style-rtl.css 71 B
build/block-library/blocks/comment-reply-link/style.css 71 B
build/block-library/blocks/comment-template/style-rtl.css 191 B
build/block-library/blocks/comment-template/style.css 191 B
build/block-library/blocks/comments-pagination-numbers/editor-rtl.css 122 B
build/block-library/blocks/comments-pagination-numbers/editor.css 121 B
build/block-library/blocks/comments-pagination/editor-rtl.css 238 B
build/block-library/blocks/comments-pagination/editor.css 231 B
build/block-library/blocks/comments-pagination/style-rtl.css 245 B
build/block-library/blocks/comments-pagination/style.css 241 B
build/block-library/blocks/comments-title/editor-rtl.css 75 B
build/block-library/blocks/comments-title/editor.css 75 B
build/block-library/blocks/comments/editor-rtl.css 842 B
build/block-library/blocks/comments/editor.css 842 B
build/block-library/blocks/comments/style-rtl.css 637 B
build/block-library/blocks/comments/style.css 637 B
build/block-library/blocks/cover/editor-rtl.css 631 B
build/block-library/blocks/cover/editor.css 631 B
build/block-library/blocks/cover/style-rtl.css 1.7 kB
build/block-library/blocks/cover/style.css 1.69 kB
build/block-library/blocks/details/editor-rtl.css 65 B
build/block-library/blocks/details/editor.css 65 B
build/block-library/blocks/details/style-rtl.css 86 B
build/block-library/blocks/details/style.css 86 B
build/block-library/blocks/embed/editor-rtl.css 331 B
build/block-library/blocks/embed/editor.css 331 B
build/block-library/blocks/embed/style-rtl.css 419 B
build/block-library/blocks/embed/style.css 419 B
build/block-library/blocks/embed/theme-rtl.css 133 B
build/block-library/blocks/embed/theme.css 133 B
build/block-library/blocks/file/editor-rtl.css 326 B
build/block-library/blocks/file/editor.css 326 B
build/block-library/blocks/file/style-rtl.css 278 B
build/block-library/blocks/file/style.css 279 B
build/block-library/blocks/footnotes/style-rtl.css 198 B
build/block-library/blocks/footnotes/style.css 197 B
build/block-library/blocks/form-input/editor-rtl.css 229 B
build/block-library/blocks/form-input/editor.css 229 B
build/block-library/blocks/form-input/style-rtl.css 349 B
build/block-library/blocks/form-input/style.css 349 B
build/block-library/blocks/form-submission-notification/editor-rtl.css 344 B
build/block-library/blocks/form-submission-notification/editor.css 341 B
build/block-library/blocks/form-submit-button/style-rtl.css 69 B
build/block-library/blocks/form-submit-button/style.css 69 B
build/block-library/blocks/freeform/editor-rtl.css 2.59 kB
build/block-library/blocks/freeform/editor.css 2.59 kB
build/block-library/blocks/gallery/editor-rtl.css 688 B
build/block-library/blocks/gallery/editor.css 691 B
build/block-library/blocks/gallery/style-rtl.css 1.83 kB
build/block-library/blocks/gallery/style.css 1.82 kB
build/block-library/blocks/gallery/theme-rtl.css 108 B
build/block-library/blocks/gallery/theme.css 108 B
build/block-library/blocks/group/editor-rtl.css 334 B
build/block-library/blocks/group/editor.css 334 B
build/block-library/blocks/group/style-rtl.css 103 B
build/block-library/blocks/group/style.css 103 B
build/block-library/blocks/group/theme-rtl.css 79 B
build/block-library/blocks/group/theme.css 79 B
build/block-library/blocks/heading/style-rtl.css 188 B
build/block-library/blocks/heading/style.css 188 B
build/block-library/blocks/html/editor-rtl.css 346 B
build/block-library/blocks/html/editor.css 347 B
build/block-library/blocks/image/style-rtl.css 1.6 kB
build/block-library/blocks/image/style.css 1.59 kB
build/block-library/blocks/image/theme-rtl.css 137 B
build/block-library/blocks/image/theme.css 137 B
build/block-library/blocks/latest-comments/style-rtl.css 355 B
build/block-library/blocks/latest-comments/style.css 354 B
build/block-library/blocks/latest-posts/editor-rtl.css 139 B
build/block-library/blocks/latest-posts/editor.css 138 B
build/block-library/blocks/latest-posts/style-rtl.css 520 B
build/block-library/blocks/latest-posts/style.css 520 B
build/block-library/blocks/list/style-rtl.css 107 B
build/block-library/blocks/list/style.css 107 B
build/block-library/blocks/loginout/style-rtl.css 61 B
build/block-library/blocks/loginout/style.css 61 B
build/block-library/blocks/media-text/editor-rtl.css 321 B
build/block-library/blocks/media-text/editor.css 320 B
build/block-library/blocks/media-text/style-rtl.css 552 B
build/block-library/blocks/media-text/style.css 550 B
build/block-library/blocks/more/editor-rtl.css 427 B
build/block-library/blocks/more/editor.css 427 B
build/block-library/blocks/navigation-link/editor-rtl.css 566 B
build/block-library/blocks/navigation-link/editor.css 568 B
build/block-library/blocks/navigation-link/style-rtl.css 192 B
build/block-library/blocks/navigation-link/style.css 191 B
build/block-library/blocks/navigation-submenu/editor-rtl.css 295 B
build/block-library/blocks/navigation-submenu/editor.css 294 B
build/block-library/blocks/navigation/editor-rtl.css 2.2 kB
build/block-library/blocks/navigation/editor.css 2.2 kB
build/block-library/blocks/navigation/style-rtl.css 2.24 kB
build/block-library/blocks/navigation/style.css 2.23 kB
build/block-library/blocks/nextpage/editor-rtl.css 392 B
build/block-library/blocks/nextpage/editor.css 392 B
build/block-library/blocks/page-list/editor-rtl.css 378 B
build/block-library/blocks/page-list/editor.css 378 B
build/block-library/blocks/page-list/style-rtl.css 192 B
build/block-library/blocks/page-list/style.css 192 B
build/block-library/blocks/paragraph/editor-rtl.css 251 B
build/block-library/blocks/paragraph/editor.css 251 B
build/block-library/blocks/paragraph/style-rtl.css 341 B
build/block-library/blocks/paragraph/style.css 340 B
build/block-library/blocks/post-author-biography/style-rtl.css 74 B
build/block-library/blocks/post-author-biography/style.css 74 B
build/block-library/blocks/post-author-name/style-rtl.css 69 B
build/block-library/blocks/post-author-name/style.css 69 B
build/block-library/blocks/post-author/editor-rtl.css 107 B
build/block-library/blocks/post-author/editor.css 107 B
build/block-library/blocks/post-author/style-rtl.css 188 B
build/block-library/blocks/post-author/style.css 189 B
build/block-library/blocks/post-comments-count/style-rtl.css 72 B
build/block-library/blocks/post-comments-count/style.css 72 B
build/block-library/blocks/post-comments-form/editor-rtl.css 96 B
build/block-library/blocks/post-comments-form/editor.css 96 B
build/block-library/blocks/post-comments-form/style-rtl.css 527 B
build/block-library/blocks/post-comments-form/style.css 528 B
build/block-library/blocks/post-comments-link/style-rtl.css 71 B
build/block-library/blocks/post-comments-link/style.css 71 B
build/block-library/blocks/post-content/style-rtl.css 61 B
build/block-library/blocks/post-content/style.css 61 B
build/block-library/blocks/post-date/style-rtl.css 62 B
build/block-library/blocks/post-date/style.css 62 B
build/block-library/blocks/post-excerpt/editor-rtl.css 71 B
build/block-library/blocks/post-excerpt/editor.css 71 B
build/block-library/blocks/post-excerpt/style-rtl.css 155 B
build/block-library/blocks/post-excerpt/style.css 155 B
build/block-library/blocks/post-featured-image/editor-rtl.css 722 B
build/block-library/blocks/post-featured-image/editor.css 720 B
build/block-library/blocks/post-featured-image/style-rtl.css 347 B
build/block-library/blocks/post-featured-image/style.css 347 B
build/block-library/blocks/post-navigation-link/style-rtl.css 215 B
build/block-library/blocks/post-navigation-link/style.css 214 B
build/block-library/blocks/post-template/style-rtl.css 414 B
build/block-library/blocks/post-template/style.css 414 B
build/block-library/blocks/post-terms/style-rtl.css 96 B
build/block-library/blocks/post-terms/style.css 96 B
build/block-library/blocks/post-time-to-read/style-rtl.css 70 B
build/block-library/blocks/post-time-to-read/style.css 70 B
build/block-library/blocks/post-title/style-rtl.css 162 B
build/block-library/blocks/post-title/style.css 162 B
build/block-library/blocks/preformatted/style-rtl.css 125 B
build/block-library/blocks/preformatted/style.css 125 B
build/block-library/blocks/pullquote/editor-rtl.css 134 B
build/block-library/blocks/pullquote/editor.css 134 B
build/block-library/blocks/pullquote/style-rtl.css 358 B
build/block-library/blocks/pullquote/style.css 358 B
build/block-library/blocks/pullquote/theme-rtl.css 167 B
build/block-library/blocks/pullquote/theme.css 167 B
build/block-library/blocks/query-pagination-numbers/editor-rtl.css 121 B
build/block-library/blocks/query-pagination-numbers/editor.css 118 B
build/block-library/blocks/query-pagination/editor-rtl.css 154 B
build/block-library/blocks/query-pagination/editor.css 154 B
build/block-library/blocks/query-pagination/style-rtl.css 237 B
build/block-library/blocks/query-pagination/style.css 237 B
build/block-library/blocks/query-title/style-rtl.css 64 B
build/block-library/blocks/query-title/style.css 64 B
build/block-library/blocks/query-total/style-rtl.css 64 B
build/block-library/blocks/query-total/style.css 64 B
build/block-library/blocks/query/editor-rtl.css 404 B
build/block-library/blocks/query/editor.css 404 B
build/block-library/blocks/quote/style-rtl.css 238 B
build/block-library/blocks/quote/style.css 238 B
build/block-library/blocks/quote/theme-rtl.css 233 B
build/block-library/blocks/quote/theme.css 236 B
build/block-library/blocks/read-more/style-rtl.css 131 B
build/block-library/blocks/read-more/style.css 131 B
build/block-library/blocks/rss/editor-rtl.css 126 B
build/block-library/blocks/rss/editor.css 126 B
build/block-library/blocks/rss/style-rtl.css 284 B
build/block-library/blocks/rss/style.css 283 B
build/block-library/blocks/search/editor-rtl.css 199 B
build/block-library/blocks/search/editor.css 199 B
build/block-library/blocks/search/style-rtl.css 660 B
build/block-library/blocks/search/style.css 658 B
build/block-library/blocks/search/theme-rtl.css 113 B
build/block-library/blocks/search/theme.css 113 B
build/block-library/blocks/separator/editor-rtl.css 100 B
build/block-library/blocks/separator/editor.css 100 B
build/block-library/blocks/separator/style-rtl.css 248 B
build/block-library/blocks/separator/style.css 248 B
build/block-library/blocks/separator/theme-rtl.css 195 B
build/block-library/blocks/separator/theme.css 195 B
build/block-library/blocks/shortcode/editor-rtl.css 286 B
build/block-library/blocks/shortcode/editor.css 286 B
build/block-library/blocks/site-logo/editor-rtl.css 773 B
build/block-library/blocks/site-logo/editor.css 770 B
build/block-library/blocks/site-logo/style-rtl.css 218 B
build/block-library/blocks/site-logo/style.css 218 B
build/block-library/blocks/site-tagline/editor-rtl.css 87 B
build/block-library/blocks/site-tagline/editor.css 87 B
build/block-library/blocks/site-tagline/style-rtl.css 65 B
build/block-library/blocks/site-tagline/style.css 65 B
build/block-library/blocks/site-title/editor-rtl.css 85 B
build/block-library/blocks/site-title/editor.css 85 B
build/block-library/blocks/site-title/style-rtl.css 143 B
build/block-library/blocks/site-title/style.css 143 B
build/block-library/blocks/social-link/editor-rtl.css 314 B
build/block-library/blocks/social-link/editor.css 314 B
build/block-library/blocks/social-links/editor-rtl.css 690 B
build/block-library/blocks/social-links/editor.css 688 B
build/block-library/blocks/social-links/style-rtl.css 1.51 kB
build/block-library/blocks/social-links/style.css 1.51 kB
build/block-library/blocks/spacer/editor-rtl.css 346 B
build/block-library/blocks/spacer/editor.css 346 B
build/block-library/blocks/spacer/style-rtl.css 48 B
build/block-library/blocks/spacer/style.css 48 B
build/block-library/blocks/table-of-contents/style-rtl.css 83 B
build/block-library/blocks/table-of-contents/style.css 83 B
build/block-library/blocks/table/editor-rtl.css 394 B
build/block-library/blocks/table/editor.css 394 B
build/block-library/blocks/table/style-rtl.css 640 B
build/block-library/blocks/table/style.css 639 B
build/block-library/blocks/table/theme-rtl.css 152 B
build/block-library/blocks/table/theme.css 152 B
build/block-library/blocks/tag-cloud/editor-rtl.css 92 B
build/block-library/blocks/tag-cloud/editor.css 92 B
build/block-library/blocks/tag-cloud/style-rtl.css 266 B
build/block-library/blocks/tag-cloud/style.css 265 B
build/block-library/blocks/template-part/editor-rtl.css 368 B
build/block-library/blocks/template-part/editor.css 368 B
build/block-library/blocks/template-part/theme-rtl.css 113 B
build/block-library/blocks/template-part/theme.css 113 B
build/block-library/blocks/term-description/style-rtl.css 126 B
build/block-library/blocks/term-description/style.css 126 B
build/block-library/blocks/text-columns/editor-rtl.css 95 B
build/block-library/blocks/text-columns/editor.css 95 B
build/block-library/blocks/text-columns/style-rtl.css 165 B
build/block-library/blocks/text-columns/style.css 165 B
build/block-library/blocks/verse/style-rtl.css 98 B
build/block-library/blocks/verse/style.css 98 B
build/block-library/blocks/video/editor-rtl.css 441 B
build/block-library/blocks/video/editor.css 442 B
build/block-library/blocks/video/style-rtl.css 192 B
build/block-library/blocks/video/style.css 192 B
build/block-library/blocks/video/theme-rtl.css 134 B
build/block-library/blocks/video/theme.css 134 B
build/block-library/classic-rtl.css 179 B
build/block-library/classic.css 179 B
build/block-library/common-rtl.css 1.08 kB
build/block-library/common.css 1.08 kB
build/block-library/editor-elements-rtl.css 75 B
build/block-library/editor-elements.css 75 B
build/block-library/elements-rtl.css 54 B
build/block-library/elements.css 54 B
build/block-library/reset-rtl.css 472 B
build/block-library/reset.css 472 B
build/block-library/style-rtl.css 15 kB
build/block-library/style.css 15 kB
build/block-library/theme-rtl.css 708 B
build/block-library/theme.css 712 B
build/block-serialization-default-parser/index.min.js 1.12 kB
build/block-serialization-spec-parser/index.min.js 2.87 kB
build/blocks/index.min.js 52.6 kB
build/commands/index.min.js 16.2 kB
build/commands/style-rtl.css 955 B
build/commands/style.css 952 B
build/components/index.min.js 229 kB
build/components/style-rtl.css 12.5 kB
build/components/style.css 12.5 kB
build/compose/index.min.js 12.8 kB
build/core-commands/index.min.js 3.09 kB
build/core-data/index.min.js 74.3 kB
build/customize-widgets/index.min.js 11 kB
build/customize-widgets/style-rtl.css 1.43 kB
build/customize-widgets/style.css 1.43 kB
build/data-controls/index.min.js 641 B
build/data/index.min.js 8.69 kB
build/date/index.min.js 18 kB
build/deprecated/index.min.js 458 B
build/dom-ready/index.min.js 325 B
build/dom/index.min.js 4.67 kB
build/edit-post/classic-rtl.css 578 B
build/edit-post/classic.css 580 B
build/edit-post/index.min.js 13.4 kB
build/edit-post/style-rtl.css 2.74 kB
build/edit-post/style.css 2.73 kB
build/edit-site/index.min.js 221 kB
build/edit-site/posts-rtl.css 7.5 kB
build/edit-site/posts.css 7.5 kB
build/edit-site/style-rtl.css 13.6 kB
build/edit-site/style.css 13.6 kB
build/edit-widgets/index.min.js 17.6 kB
build/edit-widgets/style-rtl.css 4.05 kB
build/edit-widgets/style.css 4.06 kB
build/editor/index.min.js 116 kB
build/editor/style-rtl.css 9.41 kB
build/editor/style.css 9.41 kB
build/element/index.min.js 4.82 kB
build/escape-html/index.min.js 537 B
build/format-library/index.min.js 8.07 kB
build/format-library/style-rtl.css 474 B
build/format-library/style.css 474 B
build/hooks/index.min.js 1.65 kB
build/html-entities/index.min.js 445 B
build/i18n/index.min.js 3.58 kB
build/is-shallow-equal/index.min.js 526 B
build/keyboard-shortcuts/index.min.js 1.31 kB
build/keycodes/index.min.js 1.46 kB
build/list-reusable-blocks/index.min.js 2.13 kB
build/list-reusable-blocks/style-rtl.css 852 B
build/list-reusable-blocks/style.css 852 B
build/media-utils/index.min.js 3.69 kB
build/notices/index.min.js 946 B
build/nux/index.min.js 1.62 kB
build/nux/style-rtl.css 767 B
build/nux/style.css 763 B
build/patterns/index.min.js 7.37 kB
build/patterns/style-rtl.css 687 B
build/patterns/style.css 685 B
build/plugins/index.min.js 1.86 kB
build/preferences-persistence/index.min.js 2.06 kB
build/preferences/index.min.js 2.9 kB
build/preferences/style-rtl.css 554 B
build/preferences/style.css 554 B
build/primitives/index.min.js 829 B
build/priority-queue/index.min.js 1.54 kB
build/private-apis/index.min.js 978 B
build/react-i18n/index.min.js 630 B
build/react-refresh-entry/index.min.js 9.47 kB
build/react-refresh-runtime/index.min.js 6.76 kB
build/redux-routine/index.min.js 2.7 kB
build/reusable-blocks/index.min.js 2.55 kB
build/reusable-blocks/style-rtl.css 256 B
build/reusable-blocks/style.css 256 B
build/rich-text/index.min.js 10.3 kB
build/router/index.min.js 5.42 kB
build/server-side-render/index.min.js 1.94 kB
build/shortcode/index.min.js 1.4 kB
build/style-engine/index.min.js 2.04 kB
build/token-list/index.min.js 581 B
build/url/index.min.js 3.93 kB
build/vendors/react-dom.min.js 41.7 kB
build/vendors/react-jsx-runtime.min.js 556 B
build/vendors/react.min.js 4.02 kB
build/viewport/index.min.js 965 B
build/vips/index.min.js 36.2 kB
build/warning/index.min.js 250 B
build/widgets/index.min.js 7.16 kB
build/widgets/style-rtl.css 1.16 kB
build/widgets/style.css 1.16 kB
build/wordcount/index.min.js 1.03 kB

compressed-size-action

@stokesman stokesman marked this pull request as ready for review January 15, 2025 19:25
Copy link

github-actions bot commented Jan 15, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @rickmgithub.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Unlinked contributors: rickmgithub.

Co-authored-by: stokesman <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: himanshupathak95 <[email protected]>
Co-authored-by: Infinite-Null <[email protected]>
Co-authored-by: carolinan <[email protected]>
Co-authored-by: aaronrobertshaw <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: jasmussen <[email protected]>
Co-authored-by: annezazu <[email protected]>
Co-authored-by: Robertght <[email protected]>
Co-authored-by: skorasaurus <[email protected]>
Co-authored-by: tomasztunik <[email protected]>
Co-authored-by: sinanisler <[email protected]>
Co-authored-by: draganescu <[email protected]>
Co-authored-by: tellthemachines <[email protected]>
Co-authored-by: ellatrix <[email protected]>
Co-authored-by: Mayank-Tripathi32 <[email protected]>
Co-authored-by: andreawetzel <[email protected]>
Co-authored-by: kjellr <[email protected]>
Co-authored-by: ajlende <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: jgvaldez84 <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@himanshupathak95
Copy link
Contributor

Hey @stokesman, Thanks for the PR.

This is testing well for me and covering multiple issues.

✅ The flicker issue is resolved

Screen.Recording.2025-01-16.at.14.11.44.mov

✅ The image disappearing when cropping inside a row/stack is also resolved

Screen.Recording.2025-01-16.at.14.14.12.mov

@Infinite-Null
Copy link
Contributor

Hi @stokesman,

Thank you for the PR, I have tested for disappearing image when editing (crop/rotate) auto-sized images inside flex layouts and this PR seems to solve the issue:

Screencast:

Screen.Recording.2025-01-16.at.2.44.28.PM.mov

Copy link
Contributor Author

@stokesman stokesman left a comment

Choose a reason for hiding this comment

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

I’ve added some comments that I hope can aid review.

Comment on lines -284 to -286
// The only supported unit is px, so we can parseInt to strip the px here.
const numericWidth = width ? parseInt( width, 10 ) : undefined;
const numericHeight = height ? parseInt( height, 10 ) : undefined;
Copy link
Contributor Author

@stokesman stokesman Jan 16, 2025

Choose a reason for hiding this comment

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

These became unneeded with the introduction of pixelSize that stays in sync with the displayed size of the img.

Comment on lines -288 to +287
const imageRef = useRef();
const [ imageElement, setImageElement ] = useState();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switching to state instead of a ref for the img. I suppose this isn’t strictly necessary but because the value is read during render putting it in state follows the guidance of not reading refs in render.

Comment on lines -393 to -399
function onResizeStart() {
toggleSelection( false );
}

function onResizeStop() {
toggleSelection( true );
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved into the bodies of the handlers at the actual ResizableBox JSX.

Comment on lines +920 to +924
width={ naturalWidth }
height={ naturalHeight }
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Adding these img attributes is congruent with the front end and I'm pretty sure helped in some layout context though I forget the specifics.

Comment on lines -533 to +544
const dimensionsControl = (
<DimensionsTool
value={ { width, height, scale, aspectRatio } }
onChange={ ( {
width: newWidth,
height: newHeight,
scale: newScale,
aspectRatio: newAspectRatio,
} ) => {
// Rebuilding the object forces setting `undefined`
// for values that are removed since setAttributes
// doesn't do anything with keys that aren't set.
setAttributes( {
// CSS includes `height: auto`, but we need
// `width: auto` to fix the aspect ratio when
// only height is set due to the width and
// height attributes set via the server.
width: ! newWidth && newHeight ? 'auto' : newWidth,
const dimensionsControl =
isResizable &&
( SIZED_LAYOUTS.includes( parentLayoutType ) ? (
Copy link
Contributor Author

@stokesman stokesman Jan 16, 2025

Choose a reason for hiding this comment

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

This is extraneous but it bugged me that the condition for which dimension controls would be visible was repeated in a couple places and both versions of the controls were being invoked regardless. If it helps to see it was done atomically in 6b28210.

@Mamaduka
Copy link
Member

Fantastic work, @stokesman!

I'm going to add this to the WP 6.8 project. I think this is an excellent improvement for one of the most used blocks.

@carolinan
Copy link
Contributor

I have manually tested this in different combinations of image sizes, with or without links, with borders, shadows, aspect ratios etc.
I have not found any new issues: What makes this difficult to test is that there are some problems both without Gutenberg active and with this PR applied, such as the resize handles being in the wrong position when the "Contain" option is enabled. Without more specific testing instructions, it makes it difficult to know what the expected result is.

@stokesman
Copy link
Contributor Author

Thank you for testing Carolina 🙇

the resize handles being in the wrong position when the "Contain" option is enabled

I looked into this and found the same behavior here as on trunk. I think that the position is technically correct but is likely to be confusing. The actual img size matches the resize handles but not visually because that’s what "contain" does. I'm not sure if there’s anything that can be done better in this case. If the handles match the apparent img size they would be inaccurate in regards to the aspect ratio.

Screenshot of Image block scale set to "Contain" with actual img size highlighted image-block-contain-highlight-img

Without more specific testing instructions, it makes it difficult to know what the expected result is

I take it you mean that generally and not just for the "contain" case. I find the idea of writing exhaustive specific testing instructions daunting since there are so many permutations. If I tried I’d surely miss some. I hope that we can pick out any scenarios where the expected result is unclear and come to an agreement as we go.

@carolinan
Copy link
Contributor

What I am not finding, is a conversation about why the element was needed in the first place, and if everything that the element once solved, is now fixed.

For example, this line in the removed CSS:
// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.

Is this scenario resolved?

@carolinan
Copy link
Contributor

And I think that issues should be created before pull requests. If the div created problems, they are not listed, and it makes it more difficult to review.

@stokesman
Copy link
Contributor Author

What I am not finding, is a conversation about why the element was needed in the first place, and if everything that the element once solved, is now fixed.

I’ve looked into it and haven’t found it either. For me it’s reasonable to believe the wrapper element was introduced merely for easing the implementation of the in-canvas resizing. To create a resizable element with handles the most obvious way is to have the handles be children of the element. Yet an img element can’t have children and thus adding a wrapper is the easiest workaround. For reference #2213 introduced the resizable wrapper on the img element but I didn’t see discussion along this aspect.

For example, this line in the removed CSS:
// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.

I believe I tested that well enough but I can recheck. Assuming it is resolved, I’ll get back with more detail on how it can be tested. For reference, it comes from #7721.

I think that issues should be created before pull requests. If the div created problems, they are not listed, and it makes it more difficult to review.

I'm with you and it’s part of the guidelines for non-trivial PRs. Yet there are issues that were created before this PR and are linked here so I’m not certain what I can do better. I appreciate your feedback and will consider any suggestions on how to improve this.

@aaronrobertshaw
Copy link
Contributor

Thanks for the ping for review @carolinan, unfortunately, I don't have the bandwidth to help review or test here in the near future.

I'll remove myself from the reviewers list, but it might pay to try pinging other contributors for additional eyes 🤞

Comment on lines -51 to -56
// This is necessary for the editor resize handles to accurately work on a non-floated, non-resized, small image.
.wp-block-image .components-resizable-box__container {
// Using "display: table" because:
// - it visually hides empty white space in between elements
// - it allows the element to be as wide as its contents (instead of 100% width, as it would be with `display: block`)
display: table;
Copy link
Contributor Author

@stokesman stokesman Feb 14, 2025

Choose a reason for hiding this comment

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

I'm adding some commentary here since it was asked about

Currently the comment and style are outdated because display: table is overridden by inline styles. For reference, according to #44965 (comment) it was added to hide some empty space below the image (that made the selected block outline look wrong) while also avoiding a regression of broken center alignments. In trunk, it’s overridden with display: block from inline styles that were added in #51545 and I couldn’t find discussion on that particular change but it seems to have been okay and did not regress anything.

In regards to this PR, this selector and rule applied to the wrapper around the img and now there is no wrapper. Since there is no wrapper it’s worth considering the the display of the img itself and that is not specified. From my testing everything around this works. That is, resizing "non-floated, non-resized small images" works fine. Better than on trunk since the resize handles are initially out of place on small images (less than the container’s content width) there. Also:

  • center aligned images work as expected
  • there is no empty space below the image between the selected block outline
Some markup that can be used to test such images.
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|20","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"color":{"background":"#f3d5f1"}},"fontSize":"xx-large","layout":{"type":"constrained"}} -->
<div class="wp-block-group has-background has-xx-large-font-size" style="background-color:#f3d5f1;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--20);padding-left:var(--wp--preset--spacing--20)"><!-- wp:image {"width":"32px","sizeSlug":"large","linkDestination":"none","style":{"spacing":{"margin":{"left":"var:preset|spacing|20","right":"0"}}}} -->
<figure class="wp-block-image size-large is-resized" style="margin-right:0;margin-left:var(--wp--preset--spacing--20)"><img src="https://placehold.co/10x10/crimson/white?text=%23" alt="" style="width:32px"/></figure>
<!-- /wp:image --></div>
<!-- /wp:group -->

<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|20","bottom":"var:preset|spacing|40","left":"var:preset|spacing|20","right":"var:preset|spacing|20"}},"typography":{"letterSpacing":"21px"},"color":{"background":"#f3d5f1"}},"fontSize":"xx-large","layout":{"type":"constrained","justifyContent":"center"}} -->
<div class="wp-block-group has-background has-xx-large-font-size" style="background-color:#f3d5f1;padding-top:var(--wp--preset--spacing--20);padding-right:var(--wp--preset--spacing--20);padding-bottom:var(--wp--preset--spacing--40);padding-left:var(--wp--preset--spacing--20);letter-spacing:21px"><!-- wp:image {"width":"32px","height":"auto","sizeSlug":"large","linkDestination":"none","align":"left","style":{"spacing":{"margin":{"left":"var:preset|spacing|20","right":"var:preset|spacing|20"}}}} -->
<figure class="wp-block-image alignleft size-large is-resized" style="margin-right:var(--wp--preset--spacing--20);margin-left:var(--wp--preset--spacing--20)"><img src="https://placehold.co/10x10/crimson/white?text=%23" alt="" style="width:32px;height:auto" title="fub"/></figure>
<!-- /wp:image -->

<!-- wp:paragraph -->
<p>SOMETHING</p>
<!-- /wp:paragraph --></div>
<!-- /wp:group -->

@t-hamano
Copy link
Contributor

t-hamano commented Feb 26, 2025

It turns out that this PR also resolves issue #69316. Use the following markup to apply a border to an image:

<!-- wp:image {"sizeSlug":"large","linkDestination":"none","style":{"border":{"width":"0px","style":"none"}}} -->
<figure class="wp-block-image size-large has-custom-border"><img src="https://placehold.jp/1000x400.png" alt="" style="border-style:none;border-width:0px"/></figure>
<!-- /wp:image -->

trunk

Image height and resizable box height don't match:

Details
d62e2ae4922568d134f21e1ba4ec261d.mp4

This PR

There is a slight delay, but the resizable box fits the actual image size:

Details
8dc3e6b511536d1f7bcc5aab241d4143.mp4

@carolinan carolinan added the Needs Testing Needs further testing to be confirmed. label Feb 26, 2025
@himanshupathak95
Copy link
Contributor

himanshupathak95 commented Feb 26, 2025

Thanks everybody for working on this. Here is how this PR tests for me -

✅ Issue #38381 - Images maintain proper responsive behavior and stay within their containers, even after manual resizing.

38381.mov

✅ Issue #52219 - Images with aspect ratio display at their natural size without incorrectly stretching to fill the container width.

52219.mov

✅ Issue #67506 - Images maintain consistent size when selected/deselected in various layout contexts.

67506.mov

🟨 Issue #68057 - Images inside Row/Stack blocks maintain consistent sizing between editor and frontend views. However, as can be seen, if a very large paragraph is pasted, the image shrinks almost completely which might be unexpected but I think this is a separate issue to take care of.

68057.mov

✅ Issue #68668 - Images no longer disappear when cropping in Row/Stack blocks or when aligned without specified size.

68668.mov

✅ Issue #69316 - Resize container outline properly aligns with image borders when borders are applied.

69316.mov

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thank you, @stokesman!

Could you rebase this on top of the latest trunk? Then, I think it's ready to merge.

  • The code looks good.
  • It tests well for me and others.
  • If we missed something, we could follow up with a fix.

@stokesman stokesman force-pushed the try/image-block-unwrapped branch from 54a80cd to b4356d2 Compare February 27, 2025 15:26
Copy link

Flaky tests detected in b4356d2.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/13569907912
📝 Reported issues:

@stokesman
Copy link
Contributor Author

stokesman commented Feb 27, 2025

Thanks for the review George 🙇. I’ve rebased on trunk.

  • If we missed something, we could follow up with a fix.

I have one fix in mind. The issue is technically not introduced here but I’m bringing it up because it could seem like it was. It’s a bug that manifests differently on this branch but is present on trunk. It may not be an issue on every theme but is on TT5, TT4, TT3 and TT2. It pertains to unsized images that are aligned left or right and whose innate width is larger than the content width. Thus, It’s fairly obscure. Moreover, for an image that’s aligned left or right it’s expected that the user will size it narrower than the content width and then there is no issue.

Trunk This branch
image-block-align-left-bad-size.mp4
image-block-align-left-bad-handles.mp4
The image resizes when selected (the first time) and the size (at least on some themes) doesn’t match the frontend. The resizable box’s size is constrained by the content width but the image matches what the the theme allows on the frontend

The cause is the useMaxWidthObserver hook. I’ll try a fix. I think we’d have to get it in before beta though because the problem was present in 6.7.

UPDATE: I’ve opened #69364 for this.

@stokesman stokesman merged commit d2e36e3 into trunk Feb 28, 2025
61 checks passed
@stokesman stokesman deleted the try/image-block-unwrapped branch February 28, 2025 15:04
@github-actions github-actions bot added this to the Gutenberg 20.5 milestone Feb 28, 2025
@stokesman
Copy link
Contributor Author

Folks, please pardon me. I failed to paste the props.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Image Affects the Image Block Needs Testing Needs further testing to be confirmed. [Type] Bug An existing feature does not function as intended
Projects
7 participants