Skip to content

Commit

Permalink
Image: do not display empty caption.
Browse files Browse the repository at this point in the history
  • Loading branch information
mtias committed May 5, 2017
1 parent 2aaf988 commit 9c8a9ac
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions blocks/library/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,12 @@ registerBlock( 'core/image', {
);
}

const hasCaption = caption && caption.length;

return (
<figure className="blocks-image">
<img src={ url } alt={ alt } />
{ caption || !! focus ? (
{ hasCaption || !! focus ? (
<Editable
tagName="figcaption"
placeholder={ wp.i18n.__( 'Write caption…' ) }
Expand All @@ -112,7 +114,7 @@ registerBlock( 'core/image', {
const { url, alt, caption, align = 'none' } = attributes;
const img = <img src={ url } alt={ alt } className={ `align${ align }` } />;

if ( ! caption ) {
if ( ! caption || ! caption.length ) {
return img;
}

Expand Down

0 comments on commit 9c8a9ac

Please sign in to comment.