1+ /* eslint-disable max-len */
12/**
23 * The core image rendering.
34 */
@@ -68,12 +69,10 @@ export class ImageInner extends React.Component {
6869 theme,
6970 id,
7071 image,
71- imageSource ,
72+ imageSources ,
7273 clipSvg,
7374 animation,
7475 } = this . props ;
75-
76- const imageUrl = _ . get ( imageSource , 'file.url' ) ;
7776 const clipSvgUrl = _ . get ( clipSvg , 'file.url' ) ;
7877 const imgStyle = image . extraStylesForImage ? fixStyle ( image . extraStylesForImage ) : { } ;
7978 if ( clipSvgUrl ) {
@@ -96,25 +95,47 @@ export class ImageInner extends React.Component {
9695 ) }
9796 {
9897 animation . animateOnScroll ? (
99- < img
100- src = { imageUrl }
101- alt = { image . alt || image . name }
102- style = { imgStyle }
103- data-aos = { animation . animateOnScroll }
104- data-aos-once = { animation . animateOnScrollOnce }
105- data-aos-delay = { animation . animateOnScrollDelay }
106- data-aos-duration = { animation . animateOnScrollDuration }
107- data-aos-easing = { animation . animateOnScrollEasing }
108- data-aos-mirror = { animation . animateOnScrollMirror }
109- data-aos-anchor-placement = { animation . animateOnScrollAnchor }
110- data-aos-offset = { animation . animateOnScrollOffset }
111- />
98+ < picture >
99+ < source srcSet = { imageSources . source . file . url } type = { imageSources . source . file . contentType } media = "(min-width: 769px)" />
100+ {
101+ imageSources . sourceMobile ? (
102+ < source srcSet = { imageSources . sourceMobile . file . url } type = { imageSources . sourceMobile . file . contentType } media = "(max-width: 768px)" />
103+ ) : (
104+ < source srcSet = { `${ imageSources . source . file . url } ?w=768` } type = { imageSources . source . file . contentType } media = "(max-width: 768px)" />
105+ )
106+ }
107+ < img
108+ src = { `${ imageSources . source . file . url } ?fm=png` }
109+ alt = { image . alt || image . name }
110+ style = { imgStyle }
111+ data-aos = { animation . animateOnScroll }
112+ data-aos-once = { animation . animateOnScrollOnce }
113+ data-aos-delay = { animation . animateOnScrollDelay }
114+ data-aos-duration = { animation . animateOnScrollDuration }
115+ data-aos-easing = { animation . animateOnScrollEasing }
116+ data-aos-mirror = { animation . animateOnScrollMirror }
117+ data-aos-anchor-placement = { animation . animateOnScrollAnchor }
118+ data-aos-offset = { animation . animateOnScrollOffset }
119+ loading = "lazy"
120+ />
121+ </ picture >
112122 ) : (
113- < img
114- src = { imageUrl }
115- alt = { image . alt || image . name }
116- style = { imgStyle }
117- />
123+ < picture >
124+ < source srcSet = { imageSources . source . file . url } type = { imageSources . source . file . contentType } media = "(min-width: 769px)" />
125+ {
126+ imageSources . sourceMobile ? (
127+ < source srcSet = { imageSources . sourceMobile . file . url } type = { imageSources . sourceMobile . file . contentType } media = "(max-width: 768px)" />
128+ ) : (
129+ < source srcSet = { `${ imageSources . source . file . url } ?w=768` } type = { imageSources . source . file . contentType } media = "(max-width: 768px)" />
130+ )
131+ }
132+ < img
133+ src = { `${ imageSources . source . file . url } ?fm=png` }
134+ alt = { image . alt || image . name }
135+ style = { imgStyle }
136+ loading = "lazy"
137+ />
138+ </ picture >
118139 )
119140 }
120141 </ div >
@@ -130,7 +151,7 @@ ImageInner.defaultProps = {
130151ImageInner . propTypes = {
131152 id : PT . string . isRequired ,
132153 image : PT . shape ( ) . isRequired ,
133- imageSource : PT . shape ( ) . isRequired ,
154+ imageSources : PT . shape ( ) . isRequired ,
134155 clipSvg : PT . shape ( ) ,
135156 theme : PT . shape ( {
136157 'img-wrap' : PT . string ,
0 commit comments