wordpress thumbnail image with picture tag html

Solutions on MaxInterview for wordpress thumbnail image with picture tag html by the best coders in the world

showing results for - "wordpress thumbnail image with picture tag html"
Beatrice
18 Oct 2019
1<?php 
2	// Get this attachment ID
3	$attachment_id = get_post_thumbnail_id( $post_id );
4	$image_large_src = wp_get_attachment_image_src( $attachment_id, 'large' );
5?>
6
7<picture>
8	<!-- Large art direction resolutions -->
9	<source media="(min-width: 50rem)"
10		srcset="<?php echo wp_get_attachment_image_srcset( $attachment_id, 'large' ); ?>"
11		sizes="(min-width: 60rem) 60rem, 100vw">
12
13	<!-- Small art direction resolutions -->
14	<source 
15		srcset="<?php echo wp_get_attachment_image_srcset( $attachment_id, 'large-cropped' ); ?>"
16		sizes="100vw">	
17
18	<!-- fallback -->
19	<img src="<?php echo $image_large_src[0]; ?>"
20		srcset="<?php echo wp_get_attachment_image_srcset( $image_large_id, 'large' ); ?>"
21		sizes="(min-width: 60rem) 60rem, 100vw"
22        alt="<?php get_post_meta( $attachment_id, '_wp_attachment_image_alt', true) ?>"
23	>
24</picture>
similar questions