-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Fix a bug that caused the display ratio of images to be corrupted starting from 6.3.( fix #53555 ) #53598
base: trunk
Are you sure you want to change the base?
Fix a bug that caused the display ratio of images to be corrupted starting from 6.3.( fix #53555 ) #53598
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,17 +49,30 @@ export default function save( { attributes } ) { | |
[ `wp-image-${ id }` ]: !! id, | ||
} ); | ||
|
||
const imgStyle = { aspectRatio, objectFit: scale }; | ||
|
||
// Branch by whether width and height both have size. | ||
// If the image block is very old and has not been migrated to a string type, the size will be int. | ||
// Note that only width may be "auto". | ||
if ( ! aspectRatio && height && width && 'auto' !== width ) { | ||
Comment on lines
+56
to
+57
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
const w = parseInt( width ); | ||
const h = parseInt( height ); | ||
Comment on lines
+58
to
+59
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The idea for the image block moving forward is to support units other than |
||
if ( ! isNaN( w ) && ! isNaN( h ) ) { | ||
imgStyle.aspectRatio = `${ w }/${ h }`; | ||
} | ||
} else { | ||
if ( 'string' === typeof width ) imgStyle.width = width; | ||
if ( 'string' === typeof height ) imgStyle.height = height; | ||
} | ||
Comment on lines
+57
to
+66
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic here should be moved to |
||
|
||
const image = ( | ||
<img | ||
src={ url } | ||
alt={ alt } | ||
className={ imageClasses || undefined } | ||
style={ { | ||
...borderProps.style, | ||
aspectRatio, | ||
objectFit: scale, | ||
width, | ||
height, | ||
...imgStyle, | ||
} } | ||
title={ title } | ||
/> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If
migrate
needs to be added to all these deprecations, that seems to me like a bug inapplyBlockDeprecatedVersions
, not the image block deprecations. The documentation for block deprecations doesn't mention this, and it seems rather awkward and error-prone to have to add them everywhere.