Skip to content

Commit

Permalink
Featured Image: Allow authors to select images uploaded by other users (
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka authored Jul 20, 2021
1 parent d92e2ac commit fc243d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ function PostFeaturedImageDisplay( {
);
const media = useSelect(
( select ) =>
featuredImage && select( coreStore ).getMedia( featuredImage ),
featuredImage &&
select( coreStore ).getEntityRecord(
'root',
'media',
featuredImage,
{ context: 'view' }
),
[ featuredImage ]
);
const blockProps = useBlockProps();
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/src/components/post-featured-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,16 @@ function PostFeaturedImage( {
}

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

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

0 comments on commit fc243d2

Please sign in to comment.