Skip to content

Commit

Permalink
Gallery block: Fix bug with initial image size defaulting to full size (
Browse files Browse the repository at this point in the history
#41079)

Co-authored-by: Glen Davies <glen.davies@a8c.com>
  • Loading branch information
glendaviesnz and Glen Davies committed May 16, 2022
1 parent c088c44 commit 82ecd50
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion packages/block-library/src/gallery/edit.js
Expand Up @@ -204,10 +204,11 @@ function GalleryEdit( props ) {
: undefined;
}
return {
...pickRelevantMediaFiles( imageAttributes, sizeSlug ),
...pickRelevantMediaFiles( image, sizeSlug ),
...getHrefAndDestination( image, linkTo ),
...getUpdatedLinkTargetSettings( linkTarget, attributes ),
className: newClassName,
caption: imageAttributes.caption,
sizeSlug,
};
}
Expand Down
5 changes: 3 additions & 2 deletions packages/block-library/src/gallery/shared.js
Expand Up @@ -8,11 +8,12 @@ export function defaultColumnsNumber( imageCount ) {
}

export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
const imageProps = pick( image, [ 'alt', 'id', 'link', 'caption' ] );
const imageProps = pick( image, [ 'alt', 'id', 'link' ] );
imageProps.url =
get( image, [ 'sizes', sizeSlug, 'url' ] ) ||
get( image, [ 'media_details', 'sizes', sizeSlug, 'source_url' ] ) ||
image.url;
image.url ||
image.source_url;
const fullUrl =
get( image, [ 'sizes', 'full', 'url' ] ) ||
get( image, [ 'media_details', 'sizes', 'full', 'source_url' ] );
Expand Down

0 comments on commit 82ecd50

Please sign in to comment.