Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 24 additions & 12 deletions packages/block-library/src/post-featured-image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,22 +57,30 @@ function PostFeaturedImageDisplay( {
clientId,
attributes,
setAttributes,
context: { postId, postType, queryId },
context: { postId, postType: postTypeSlug, queryId },
} ) {
const isDescendentOfQueryLoop = Number.isFinite( queryId );
const { isLink, height, width, scale, sizeSlug } = attributes;
const [ featuredImage, setFeaturedImage ] = useEntityProp(
'postType',
postType,
postTypeSlug,
'featured_media',
postId
);

const media = useSelect(
( select ) =>
featuredImage &&
select( coreStore ).getMedia( featuredImage, { context: 'view' } ),
[ featuredImage ]
const { media, postType } = useSelect(
( select ) => {
const { getMedia, getPostType } = select( coreStore );
return {
media:
featuredImage &&
getMedia( featuredImage, {
context: 'view',
} ),
postType: postTypeSlug && getPostType( postTypeSlug ),
};
},
[ featuredImage, postTypeSlug ]
);
const mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );

Expand Down Expand Up @@ -124,11 +132,15 @@ function PostFeaturedImageDisplay( {
<InspectorControls>
<PanelBody title={ __( 'Link settings' ) }>
<ToggleControl
label={ sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType
) }
label={
postType?.labels.singular_name
? sprintf(
// translators: %s: Name of the post type e.g: "post".
__( 'Link to %s' ),
postType.labels.singular_name.toLowerCase()
)
: __( 'Link to post' )
Comment thread
ntsekouras marked this conversation as resolved.
Resolved
}
onChange={ () => setAttributes( { isLink: ! isLink } ) }
checked={ isLink }
/>
Expand Down