Hi, the sizes
value returned is not the sizes
attribute in responsive image. It's an array of the following info:
[sizes] => Array
(
[thumbnail] => Array
(
[file] => press_image-150x150.jpg
[width] => 150
[height] => 150
[mime-type] => image/jpeg
)
[medium] => Array
(
[file] => press_image-4-300x194.jpg
[width] => 300
[height] => 194
[mime-type] => image/jpeg
)
[large] => Array
(
[file] => press_image-1024x665.jpg
[width] => 1024
[height] => 665
[mime-type] => image/jpeg
)
[post-thumbnail] => Array
(
[file] => press_image-624x405.jpg
[width] => 624
[height] => 405
[mime-type] => image/jpeg
)
)
To get the sizes
attribute, we can use the following function:
wp_calculate_image_sizes( $size, $image_src = null, $image_meta = null, $attachment_id = 0 )
So, in your code, you can do like this:
foreach ( $images as $image ) {
$sizes = wp_calculate_image_sizes( array( $image['width'], $image['height'] ), null, null, $image['ID'] );
echo "\n<a href='{$image['full_url']}'>\n<img src='{$image['url']}' width='{$image['width']}' height='{$image['height']}' alt='{$image['alt']}' srcset='{$image['srcset']}' sizes='{$sizes}'>\n</a>";
}