Skip to content

Commit

Permalink
Fix: Preserve Display Preview State in File Block (#67263)
Browse files Browse the repository at this point in the history
Co-authored-by: Sukhendu2002 <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: MadtownLems <[email protected]>
  • Loading branch information
4 people authored Nov 25, 2024
1 parent 7e9e53d commit 21ee975
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/block-library/src/file/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,21 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
}

const isPdf = newMedia.url.endsWith( '.pdf' );
const pdfAttributes = {
displayPreview: isPdf
? attributes.displayPreview ?? true
: undefined,
previewHeight: isPdf ? attributes.previewHeight ?? 600 : undefined,
};

setAttributes( {
href: newMedia.url,
fileName: newMedia.title,
textLinkHref: newMedia.url,
id: newMedia.id,
displayPreview: isPdf ? true : undefined,
previewHeight: isPdf ? 600 : undefined,
fileId: `wp-block-file--media-${ clientId }`,
blob: undefined,
...pdfAttributes,
} );
setTemporaryURL();
}
Expand Down

0 comments on commit 21ee975

Please sign in to comment.