I have a custom post type. Inside loop of single post template I'm trying to show a featured image with custom srcset
attribute.
My image sizes are:
add_image_size( 'i600', 600 );
add_image_size( 'i1000', 1000 );
add_image_size( 'i1200', 1200 );
add_image_size( 'i1800', 1800 );
I'm trying this:
$img_id = get_post_thumbnail_id($post->ID);
$img_src = wp_get_attachment_image_url( $img_id, 'i1200' );
$img_srcset = wp_get_attachment_image_srcset( $img_id, array( 'i600', 'i1000', 'i1200' ) );
$img_src
returns right URL but var_dump($img_srcset);
returns false
Why $img_srcset
is returning false?
Aditional info
wp_get_attachment_metadata( $img_id )
returns: https://pastebin.com/pfyFMPvb
WP 4.8
wp_get_attachment_image_srcset()
with multiple image sizes. Try a single image size instead or an array of width and height. – birgire Jun 11 '17 at 17:41