Betiok
7/2/2017 - 11:26 AM

Image srcset

Image srcset

<?php if ( has_post_thumbnail()) : ?>
	<?php
		$thumbnail_id = get_post_thumbnail_id();
		$thumbnail_alt = get_post_meta($thumbnail_id, '_wp_attachment_image_alt', true);
		$thumbnail_small = wp_get_attachment_image_src($thumbnail_id, 'small');
		$thumbnail_large = wp_get_attachment_image_src($thumbnail_id, 'large');
	?>

	<img srcset="<?php echo $thumbnail_large[0]; ?> 480w, <?php echo $thumbnail_small[0]; ?> 1280w" src="<?php echo $thumbnail_small[0]; ?>" alt="<?php echo $thumbnail_alt; ?>" />
<?php endif; ?>
<img srcset="<?php echo $thumbnails['sizes']['gallery-4']; ?> 480w, <?php echo $thumbnails['sizes']['gallery-1']; ?> 1280w" src="<?php echo $thumbnails['sizes']['gallery-1']; ?>" alt="<?php echo $thumbnails['alt']; ?>" />