From aea33a3a905435c0b8dad3227c94418e202c38fb Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Tue, 30 Oct 2018 13:57:03 -0400 Subject: [PATCH 1/2] Use source_url for media file link URL in image block --- packages/block-library/src/image/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index 1ff353c1ada4d..b10ab80c5aea7 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -168,7 +168,7 @@ class ImageEdit extends Component { if ( value === LINK_DESTINATION_NONE ) { href = undefined; } else if ( value === LINK_DESTINATION_MEDIA ) { - href = this.props.attributes.url; + href = this.props.image.source_url; } else if ( value === LINK_DESTINATION_ATTACHMENT ) { href = this.props.image && this.props.image.link; } else { From eba448f86a377794a613909017cd29ad505210d3 Mon Sep 17 00:00:00 2001 From: William Earnhardt Date: Tue, 30 Oct 2018 14:39:46 -0400 Subject: [PATCH 2/2] Account for external images in media file link --- packages/block-library/src/image/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/block-library/src/image/edit.js b/packages/block-library/src/image/edit.js index b10ab80c5aea7..ce52f131075bc 100644 --- a/packages/block-library/src/image/edit.js +++ b/packages/block-library/src/image/edit.js @@ -168,7 +168,7 @@ class ImageEdit extends Component { if ( value === LINK_DESTINATION_NONE ) { href = undefined; } else if ( value === LINK_DESTINATION_MEDIA ) { - href = this.props.image.source_url; + href = ( this.props.image && this.props.image.source_url ) || this.props.attributes.url; } else if ( value === LINK_DESTINATION_ATTACHMENT ) { href = this.props.image && this.props.image.link; } else {