Home › Forums › Front-end Issues › Cannot get srcset to output anything › Reply To: Cannot get srcset to output anything
Hm, I’ve tried this. Re-uploaded my images but still only 1 size is being output in the sizes attribute
Isn’t $image_size = ‘project-full’; effectively saying to use only that image size?
Seems to be the same thing happening with this function:
function awesome_acf_responsive_image($image_id,$image_size,$max_width){
// check the image ID is not blank
if($image_id != '') {
// set the default src image size
$image_src = wp_get_attachment_image_url( $image_id, $image_size );
// set the srcset with various image sizes
$image_srcset = wp_get_attachment_image_srcset( $image_id, $image_size );
// generate the markup for the responsive image
echo 'src="'.$image_src.'" srcset="'.$image_srcset.'" sizes="(max-width: '.$max_width.') 100vw, '.$max_width.'"';
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.