Skip to content

Commit

Permalink
Strip HTML from caption when saving as alt attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Oct 29, 2020
1 parent 5d7ebd1 commit 898b5f8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/block-library/src/gallery/save.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* WordPress dependencies
*/
import { RichText } from '@wordpress/block-editor';
import { __unstableStripHTML } from '@wordpress/dom';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,7 +44,11 @@ export default function save( { attributes } ) {
const img = (
<img
src={ image.url }
alt={ image.alt !== '' ? image.alt : image.caption }
alt={
image.alt !== ''
? image.alt
: __unstableStripHTML( image.caption )
}
data-id={ image.id }
data-full-url={ image.fullUrl }
data-link={ image.link }
Expand Down

0 comments on commit 898b5f8

Please sign in to comment.