diff --git a/php/class-media.php b/php/class-media.php index c23990305..3c9d1cf6c 100644 --- a/php/class-media.php +++ b/php/class-media.php @@ -1874,6 +1874,7 @@ public function image_srcset( $sources, $size_array, $image_src, $image_meta, $a if ( ! $cloudinary_id ) { return $sources; // Return WordPress default sources. } + // Get transformations if any. $transformations = Relate::get_transformations( $attachment_id ); @@ -1925,6 +1926,11 @@ function ( $item ) use ( $crop ) { } } + // Handle unexpected sources variable type. + if ( ! is_array( $sources ) ) { + return $sources; + } + // Add the main size as the largest srcset src. $crop = $this->get_crop_from_transformation( $transformations ); if ( ! empty( $crop ) ) {