Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 130709

How to fix srcset issue?

$
0
0

Replies: 0

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 minute ago by yurenlimbu. Reason: Code align

Viewing all articles
Browse latest Browse all 130709

Trending Articles