Home Forums Front-end Issues Cannot get srcset to output anything Reply To: Cannot get srcset to output anything

  • So, when I use the above I get just the ID of the image field in question.

    $image_size = 'the image size you want to use';
    $image_id = get_field('your image field name', false, false);
    $image = wp_get_attachment_image_src($image_id, $image_size);
    if ($image) {
      $image_alt = get_post_meta($image_id, '_wp_attachment_image_alt', true);
      if (!$image_alt) {
        $image_alt = get_the_title($post_id);
      $image_tag = '<img src="'.$image[0].'" width="'.$image[1].
                   '" height="'.$image[2].'" alt="'.$image_alt.
                   '" class="size-'.$image_size.' wp-image-'.$image_id.'" />';
      $image_tag = wp_make_content_images_responsive($image_tag);
      echo $image_tag;