From 205d43674e4160ecdb363e7684359d04dd00db8c Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Mon, 19 Aug 2019 11:53:26 -0700 Subject: [PATCH] Harden logic for normalizing image metadata before adding story images --- includes/class-amp-story-media.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/includes/class-amp-story-media.php b/includes/class-amp-story-media.php index 4323bcaba66..af8312c01c2 100644 --- a/includes/class-amp-story-media.php +++ b/includes/class-amp-story-media.php @@ -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(