Skip to content

Commit

Permalink
Image block and behaviors: Fix some warnings (#52109)
Browse files Browse the repository at this point in the history
* Fix first warning

* Fix second warning - dividing a NaN
  • Loading branch information
cbravobernal authored and tellthemachines committed Jul 7, 2023
1 parent 91a3458 commit 2930ef4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/experimental/interactivity-api/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
function gutenberg_block_update_interactive_view_script( $metadata ) {
if (
array_key_exists( 'name', $metadata ) &&
in_array( $metadata['name'], array( 'core/image' ), true ) &&
array_key_exists( 'file', $metadata ) &&
str_contains( $metadata['file'], 'build/block-library/blocks' )
) {
$metadata['viewScript'] = array( 'file:./interactivity.min.js' );
Expand Down
3 changes: 2 additions & 1 deletion packages/block-library/src/image/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,8 @@ export default function Image( {
const ratio =
( aspectRatio && evalAspectRatio( aspectRatio ) ) ||
( width && height && width / height ) ||
naturalWidth / naturalHeight;
naturalWidth / naturalHeight ||
1;

const currentWidth = ! width && height ? height * ratio : width;
const currentHeight = ! height && width ? width / ratio : height;
Expand Down

0 comments on commit 2930ef4

Please sign in to comment.