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
Media & Text block should not use background image #52789
Media & Text has the setting "Crop image to fill entire column". When it's on, the img tag is visually hidden and the figure gets a background image applied. I agree with @tkapler, this ought to be updated to use object-fit on the img instead.
The Meda & Text block has a Focal Point Picker, but I think it can be handled by object-fit and object-position, just as the Cover block is so implemented.
This was fixed in #64981, now in trunk. Old markup should still work correctly using background-image, but new markup will use object-fit instead. Editing old markup should upgrade it to new markup automatically, as you're used to with other blocks that have gone through deprecations.
Activity
t-hamano commentedon Jul 20, 2023
Hi @tkapler,
Thanks for the report.
Are you referring to Media & Text block? If so, the image is rendered as an
imgtag.stokesman commentedon Jul 20, 2023
Media & Text has the setting "Crop image to fill entire column". When it's on, the
imgtag is visually hidden and thefiguregets a background image applied. I agree with @tkapler, this ought to be updated to useobject-fiton theimginstead.t-hamano commentedon Jul 21, 2023
I see, I had missed that 😅
The Meda & Text block has a Focal Point Picker, but I think it can be handled by
object-fitandobject-position, just as the Cover block is so implemented.[-]Image+Text block should not use background image[/-][+]Media & Text block should not use background image[/+]joemcgill commentedon Nov 27, 2023
Additionally, when a background image is used, the original
imgelement is still in the DOM, but is hidden using CSS, which can lead to two different files being loaded depending on how thesrcsetandsizesattributes on the hidden image are configured. See: https://github.com/WordPress/gutenberg/blob/wp/6.4/packages/block-library/src/media-text/style.scss#L89-L99nicomollet commentedon Mar 21, 2024
I added a PR two months ago, can someone take at look at it?
sgomes commentedon Sep 4, 2024
This was fixed in #64981, now in trunk. Old markup should still work correctly using
background-image, but new markup will useobject-fitinstead. Editing old markup should upgrade it to new markup automatically, as you're used to with other blocks that have gone through deprecations.Please let me know if you come across any bugs!