Skip to content

Commit

Permalink
Don't render if there is no URL set
Browse files Browse the repository at this point in the history
  • Loading branch information
t-hamano committed Oct 22, 2022
1 parent 5218484 commit cf52578
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/block-library/src/image/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
* @return string Returns the block content with the data-id attribute added.
*/
function render_block_core_image( $attributes, $content ) {

// Don't render if there is no URL set.
$processor = new WP_HTML_Tag_Processor( $content );
$processor->next_tag( 'img' );

if ( $processor->get_attribute( 'src' ) === null ) {
return '';
}

if ( isset( $attributes['data-id'] ) ) {
// Add the data-id="$id" attribute to the img element
// to provide backwards compatibility for the Gallery Block,
Expand Down

0 comments on commit cf52578

Please sign in to comment.