From 8c57e5cb0de800e6c614e2f55f622525288f2460 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Wed, 14 Feb 2024 15:07:45 +0400 Subject: [PATCH] Inserter: Fix title condition for media tab previews (#58993) Unlinked contributors: nbcsteveb. Co-authored-by: Mamaduka Co-authored-by: ntsekouras --- .../src/components/inserter/media-tab/media-preview.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/block-editor/src/components/inserter/media-tab/media-preview.js b/packages/block-editor/src/components/inserter/media-tab/media-preview.js index 9efed229f0adf..d3b221910eae2 100644 --- a/packages/block-editor/src/components/inserter/media-tab/media-preview.js +++ b/packages/block-editor/src/components/inserter/media-tab/media-preview.js @@ -195,7 +195,12 @@ export function MediaPreview( { media, onClick, category } ) { createSuccessNotice, ] ); - const title = media.title?.rendered || media.title; + + const title = + typeof media.title === 'string' + ? media.title + : media.title?.rendered || __( 'no title' ); + let truncatedTitle; if ( title.length > MAXIMUM_TITLE_LENGTH ) { const omission = '...';