Skip to content

Commit

Permalink
Featured Image: Use getMedia shorthand (#33943)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Aug 9, 2021
1 parent a1c63c2 commit 165b92a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
7 changes: 1 addition & 6 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,7 @@ function PostFeaturedImageDisplay( {
const media = useSelect(
( select ) =>
featuredImage &&
select( coreStore ).getEntityRecord(
'root',
'media',
featuredImage,
{ context: 'view' }
),
select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
[ featuredImage ]
);
const blockProps = useBlockProps( {
Expand Down
6 changes: 2 additions & 4 deletions packages/editor/src/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,13 @@ function PostFeaturedImage( {
}

const applyWithSelect = withSelect( ( select ) => {
const { getEntityRecord, getPostType } = select( coreStore );
const { getMedia, getPostType } = select( coreStore );
const { getCurrentPostId, getEditedPostAttribute } = select( editorStore );
const featuredImageId = getEditedPostAttribute( 'featured_media' );

return {
media: featuredImageId
? getEntityRecord( 'root', 'media', featuredImageId, {
context: 'view',
} )
? getMedia( featuredImageId, { context: 'view' } )
: null,
currentPostId: getCurrentPostId(),
postType: getPostType( getEditedPostAttribute( 'type' ) ),
Expand Down

0 comments on commit 165b92a

Please sign in to comment.