Skip to content

Commit

Permalink
Harden logic for normalizing image metadata before adding story images
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter committed Aug 19, 2019
1 parent cc10a5d commit 205d436
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions includes/class-amp-story-media.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,12 @@ public static function filter_schemaorg_metadata_images( $data ) {
return $data;
}

if ( ! isset( $data['image'] ) ) {
$data['image'] = [];
} elseif ( is_string( $data['image'] ) ) {
if ( is_string( $data['image'] ) ) {
$data['image'] = [ $data['image'] ];
} elseif ( isset( $data['image']['@type'] ) ) {
} elseif ( is_array( $data['image'] ) && isset( $data['image']['@type'] ) ) {
$data['image'] = [ $data['image'] ];
} elseif ( ! is_array( $data['image'] ) ) {
$data['image'] = [];
}

$data['image'] = array_merge(
Expand Down

0 comments on commit 205d436

Please sign in to comment.