Skip to content

Commit

Permalink
ImageBlock: apply width class to figure when using captions. (#1358)
Browse files Browse the repository at this point in the history
  • Loading branch information
mtias authored Jun 22, 2017
1 parent 5c24018 commit 2b4f754
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions blocks/library/image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,15 +113,15 @@ registerBlockType( 'core/image', {

save( { attributes } ) {
const { url, alt, caption, align = 'none' } = attributes;
const img = <img src={ url } alt={ alt } className={ `align${ align }` } />;

// If there's no caption set only save the image element.
if ( ! caption || ! caption.length ) {
return img;
return <img src={ url } alt={ alt } className={ `align${ align }` } />;
}

return (
<figure>
{ img }
<figure className={ `align${ align }` }>
<img src={ url } alt={ alt } />
<figcaption>{ caption }</figcaption>
</figure>
);
Expand Down

0 comments on commit 2b4f754

Please sign in to comment.