From aedd241bae2430099c66508349beeecc9ce218b2 Mon Sep 17 00:00:00 2001 From: Enrique Piqueras Date: Tue, 24 Sep 2019 12:36:07 -0700 Subject: [PATCH] Image Block: Improve performance by only requesting image metadata if selected. (#17504) --- packages/block-library/src/image/edit.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 9ee5101226cb2e..bbca559088299f 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -939,7 +939,7 @@ export default compose( [ withSelect( ( select, props ) => { const { getMedia } = select( 'core' ); const { getSettings } = select( 'core/block-editor' ); - const { id } = props.attributes; + const { attributes: { id }, isSelected } = props; const { __experimentalMediaUpload, imageSizes, @@ -948,7 +948,7 @@ export default compose( [ } = getSettings(); return { - image: id ? getMedia( id ) : null, + image: id && isSelected ? getMedia( id ) : null, maxWidth, isRTL, imageSizes,