Skip to content

Commit

Permalink
checks if caption is empty in media lib and keeps the one written in …
Browse files Browse the repository at this point in the history
…block
  • Loading branch information
draganescu committed Jan 15, 2020
1 parent b448074 commit 6b49f7c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,13 @@ export class ImageEdit extends Component {

let mediaAttributes = pickRelevantMediaFiles( media );

// If the current image is temporary but an alt or caption text was meanwhile written by the user,
// make sure the text is not overwritten.
if ( isTemporaryImage( id, url ) ) {
if ( alt ) {
mediaAttributes = omit( mediaAttributes, [ 'alt' ] );
}
if ( caption ) {
mediaAttributes = omit( mediaAttributes, [ 'caption' ] );
}
// If an alt or caption text was meanwhile written by the user,
// make sure the text is not overwritten by empty captions
if ( alt || ! get( mediaAttributes, [ 'alt' ] ) ) {
mediaAttributes = omit( mediaAttributes, [ 'alt' ] );
}
if ( caption || ! get( mediaAttributes, [ 'caption' ] ) ) {
mediaAttributes = omit( mediaAttributes, [ 'caption' ] );
}

let additionalAttributes;
Expand Down

0 comments on commit 6b49f7c

Please sign in to comment.