Skip to content

Commit

Permalink
Prevent media requests if block is not selected
Browse files Browse the repository at this point in the history
  • Loading branch information
mmtr committed Dec 16, 2019
1 parent 4a43b08 commit 3c6f371
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/block-library/src/gallery/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -389,17 +389,18 @@ class GalleryEdit extends Component {
}
}
export default compose( [
withSelect( ( select, { attributes: { ids } } ) => {
withSelect( ( select, { attributes: { ids }, isSelected } ) => {
const { getMedia } = select( 'core' );
const { getSettings } = select( 'core/block-editor' );
const {
imageSizes,
mediaUpload,
} = getSettings();

const resizedImages = reduce(
ids,
( currentResizedImages, id ) => {
let resizedImages = {};

if ( isSelected ) {
resizedImages = reduce( ids, ( currentResizedImages, id ) => {
if ( ! id ) {
return currentResizedImages;
}
Expand All @@ -416,8 +417,8 @@ export default compose( [
...currentResizedImages,
[ parseInt( id, 10 ) ]: sizes,
};
},
{} );
}, {} );
}

return {
imageSizes,
Expand Down

0 comments on commit 3c6f371

Please sign in to comment.