I am trying to get an image with it’s srcset
attribute for all the image sizes using wp_get_attachment_image(). But it seems like the “full” (original) size is not listed:
<?php echo wp_get_attachment_image( $imageid, 'medium', false, $image_attributes); ?>
Gives: (I excluded non relevant attributes)
<img src="https://wordpress.stackexchange.com/questions/267550/...image-232x300.jpg"
srcset="https://wordpress.stackexchange.com/...image-232x300.jpg 232w,
https://wordpress.stackexchange.com/...image-768x994.jpg 768w,
https://wordpress.stackexchange.com/...image-791x1024.jpg 791w">
Is this the expected output? How should I include full size (…image.jpg in this case) in the srcset
attribute?
I noticed that calling <?php echo wp_get_attachment_image( $imageid, 'full', false, $image_attributes); ?>
doesn’t include the full size in srcset
but still makes use of it if it is needed, as it is the assigned to the src
. This seems to work well with browsers that support srcset
(I checked network calls and only the necessary image size is called). But I am concerned to assign the full size to the src
in browsers that don’t support srcset
feature.