Skip to content

Commit

Permalink
Update gutenberg_render_block_core_image()
Browse files Browse the repository at this point in the history
Return early when the block is not `core/image`.
  • Loading branch information
azaozz committed Nov 28, 2018
1 parent 4b0425f commit 648811f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/compat.php
Original file line number Diff line number Diff line change
Expand Up @@ -473,8 +473,8 @@ function gutenberg_get_image_width_height( $block_attributes, $image_meta = null
* @return string Filtered Image block HTML.
*/
function gutenberg_render_block_core_image( $html, $block ) {
// Old post or... something's wrong.
if ( empty( $html ) || empty( $block['attrs'] ) ) {
// Return early if different block or no attributes.
if ( empty( $html ) || empty( $block['attrs'] ) || $block['blockName'] !== 'core/image' ) {
return $html;
}

Expand All @@ -488,7 +488,7 @@ function gutenberg_render_block_core_image( $html, $block ) {
$block_attributes = wp_parse_args( $block['attrs'], $defaults );

if ( empty( $block_attributes['url'] ) ) {
// We don't have enough data to construct new img tag. Fall back to the existing HTML.
// Old block format? No enough data to construct new img tag. Fall back to the existing HTML.
return $html;
}

Expand Down

0 comments on commit 648811f

Please sign in to comment.