From 6245e90a0f99b0f7d72811ac199f04fce7176842 Mon Sep 17 00:00:00 2001 From: iseulde Date: Mon, 8 Jan 2018 13:14:39 +0100 Subject: [PATCH] Image: set width if aligned but unresized --- blocks/library/image/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/blocks/library/image/index.js b/blocks/library/image/index.js index 9f3802080d404b..3a49ee6e8a416c 100644 --- a/blocks/library/image/index.js +++ b/blocks/library/image/index.js @@ -155,9 +155,16 @@ registerBlockType( 'core/image', { save( { attributes } ) { const { url, alt, caption, align, href, width, height } = attributes; const extraImageProps = width || height ? { width, height } : {}; - const figureStyle = width ? { width } : {}; const image = {; + let figureStyle = {}; + + if ( width ) { + figureStyle = { width }; + } else if ( align === 'left' || align === 'right' ) { + figureStyle = { maxWidth: '50%' }; + } + return (
{ href ? { image } : image }