Skip to content

Commit f93c53b

Browse files
authored
Merge pull request #1020 from cloudinary/update/media-sources
Ensure sources are an array in srcset hook.
2 parents bc53f8c + 3fe0646 commit f93c53b

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

php/class-media.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1874,6 +1874,7 @@ public function image_srcset( $sources, $size_array, $image_src, $image_meta, $a
18741874
if ( ! $cloudinary_id ) {
18751875
return $sources; // Return WordPress default sources.
18761876
}
1877+
18771878
// Get transformations if any.
18781879
$transformations = Relate::get_transformations( $attachment_id );
18791880

@@ -1925,6 +1926,11 @@ function ( $item ) use ( $crop ) {
19251926
}
19261927
}
19271928

1929+
// Handle unexpected sources variable type.
1930+
if ( ! is_array( $sources ) ) {
1931+
return $sources;
1932+
}
1933+
19281934
// Add the main size as the largest srcset src.
19291935
$crop = $this->get_crop_from_transformation( $transformations );
19301936
if ( ! empty( $crop ) ) {

0 commit comments

Comments
 (0)