Skip to content

Commit

Permalink
Merge pull request #21168 from Yoast/1394-major-222-image-object-shou…
Browse files Browse the repository at this point in the history
…ld-not-be-output-on-webpage-and-article-in-case-image-was-not-added-to-the-post

Make sure image is null when it is '' so that the schema generator does not create an empty record.
  • Loading branch information
vraja-pro authored Feb 22, 2024
2 parents 62ce5d0 + b16ae6e commit 4195808
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/context/meta-tags-context.php
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,11 @@ private function get_main_image_url_for_rest_request() {
switch ( $this->page_type ) {
case 'Post_Type':
if ( $this->post instanceof WP_Post ) {
return $this->image->get_post_content_image( $this->post->ID );
$url = $this->image->get_post_content_image( $this->post->ID );
if ( $url === '' ) {
return null;
}
return $url;
}
return null;
default:
Expand Down

0 comments on commit 4195808

Please sign in to comment.