Skip to content

Commit

Permalink
Reuse code for detecting temporary media
Browse files Browse the repository at this point in the history
  • Loading branch information
Mamaduka committed Jun 24, 2021
1 parent 17f897a commit a65cbf2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/block-library/src/media-text/media-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function MediaContainer( props, ref ) {
onWidthChange,
} = props;

const isTemporaryMedia = ! mediaId && isBlobURL( mediaUrl );

const { toggleSelection } = useDispatch( blockEditorStore );

if ( mediaUrl ) {
Expand Down Expand Up @@ -152,7 +154,7 @@ function MediaContainer( props, ref ) {
className={ classnames(
className,
'editor-media-container__resizer',
{ 'is-transient': isBlobURL( mediaUrl ) }
{ 'is-transient': isTemporaryMedia }
) }
style={ backgroundStyles }
size={ { width: mediaWidth + '%' } }
Expand All @@ -173,7 +175,7 @@ function MediaContainer( props, ref ) {
mediaId={ mediaId }
/>
{ ( mediaTypeRenderers[ mediaType ] || noop )() }
{ isBlobURL( mediaUrl ) && <Spinner /> }
{ isTemporaryMedia && <Spinner /> }
<PlaceholderContainer { ...props } />
</ResizableBoxContainer>
);
Expand Down

0 comments on commit a65cbf2

Please sign in to comment.