Default image size ignored in Media Text block
Description
If you add an image larger than the image size 'large' and save it without changing anything else, the frontend only shows the 'large' image size.
You need to select a different image size than the default (which is 'full') and then change it back to get the real full width image displayed in the frontend.
In the markup, the size-<media-slug> class is also missing before you change the image size manually.
Step-by-step reproduction instructions
- Create a Media Text block
- Add an image, that is larger than the "large" image size, so that you have a full width image size
- Save the post
- Visit the post in the frontend
Screenshots, screen recording, code snippet
No response
Environment info
– WordPress 5.9 – No Gutenberg plugin – Theme: Twenty Twenty-Two – macOS
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
No
Hi,
I am only able to reproduce this partially.
The image source width is set to 1024 (large), if I select an image that is larger than 1024.
But the CSS class name is not missing in my test, it is size-full if a pick an image larger than 1024 but also if I pick an image smaller than 150 (thumbnail).
Tested using WordPress 6.0-beta3-53290 and WordPress 5.9.3 with and without Gutenberg.
I think the max width of 1024 is reasonable -or even too high. I think many users will use the default values, and if the image was shown using the full size, it may slow down their websites.
I have come across this bug too - the image size dropdown appears to show Full Size is selected but will only display large no matter what screen size or screen density is used. You need to select another size then go back to full to get the full size to display.
If you believe that the full size shouldn't be the default then the dropdown shouldn't show that by default when it's not correct.
Just wanted to add that I also have this issue (when adding a new Media-Text block with an image, it supposedly defaults to 'Full size' in the size dropdown, but actually output a 'Large' image unless you change to thumbnail (or other) and back again).
Surely this is not intended functionality and should be resolved? Is this in the pipeline to fix? I understand it's unlikely to affect the majority of users, as it will be rare where ~1024px isn't wide enough not to be blurry - but in circumstances where the media-text block is used 50/50 full width on a 2K screen (for example) those default images become blurry.
I faced the same bug, I think. I created a pattern with a media-text block and tried to set up a media size to thumbnail:
<!-- wp:media-text {"mediaWidth":25,"mediaSizeSlug":"thumbnail"} -->
<div class="wp-block-media-text is-stacked-on-mobile" style="grid-template-columns:25% auto"><figure class="wp-block-media-text__media"></figure><div class="wp-block-media-text__content"><!-- wp:heading {"level":4} -->
<h4 class="wp-block-heading">Title</h4>
<!-- /wp:heading -->
<!-- wp:paragraph -->
<p>Description</p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->
When I use this pattern in the editor and add an image, in the sidebar image resolution dropdown I see that the size is a Thumbnail, but on the website I see that it generates a Large image, and I would expect it to be a thumbnail size.
I can still reproduce it on trunk. When an image is selected, the Media & Text block always uses the "large" URL but never stores mediaSizeSlug. So the Resolution control and the saved size-* class fall back to full, while the front end shows the large image. A mediaSizeSlug already set on the block (for example in a pattern) is also ignored.
Proposed approach, matching what the Image and Cover blocks already do: when an image is selected, use the block's current mediaSizeSlug if the image has that size, otherwise the site's default image size (imageDefaultSize, large by default), otherwise full. Then store the chosen size in mediaSizeSlug. This keeps the image URL, the Resolution control and the size-* class in sync without changing the saved markup, so no block deprecation is needed. The default stays large, so performance doesn't change.