Support » Developing with WordPress » How to fix srcset issue?

  • Image using this code. Example link

    <?php
    $img_src = wp_get_attachment_image_url( $attachment_id, 'thumbnail_16_10' );
    $img_srcset = wp_get_attachment_image_srcset( $attachment_id, 'thumbnail_16_10' );
    ?>
    <img src="<?php echo esc_url( $img_src ); ?>"
         srcset="<?php echo esc_attr( $img_srcset ); ?>"
         sizes="(max-width: 50em) 87vw, 680px" alt="A rad wolf">

    Image sizes:

    add_action('init', 'add_image_sizes');
    function add_image_sizes() {
      add_image_size( 'thumbnail_260', 260, 260, true );
      add_image_size( 'thumbnail_360', 360, 360, true );
      add_image_size( 'thumbnail_16_10', 560, 350, true );
      add_image_size( 'thumbnail_4_3', 640, 854, true );
    }

    Result:
    srcset(unknown) screenshot

    How can I fix this issue.

    • This topic was modified 1 year, 8 months ago by  yurenlimbu. Reason: Code align
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to fix srcset issue?’ is closed to new replies.