Released React DatoCMS Image component v4
Basically, with react-datocms v4.0.0 your responsiveImage() GraphQL queries can be reduced down to:
responsiveImage(imgixParams: { auto: format }) { src width height alt base64}You can avoid requesting
srcSetin theresponsiveImageGraphQL query, as if it's missing, the React<Image />component knows how to build it fromsrc.You can avoid requesting
webpSrcSetas well, because the{ auto: format }Imgix transformation parameter offers even more performant optimizations (AVIF), without increasing the GraphQL response size.You can avoid requesting
sizes, and just use thesizesprop on the Image component itself.
Overall, these changes can reduce the overall GraphQL response size significantly, especially when dealing with many images at once.
New props for Image component:
priority: When true, the image will be considered high priority. Lazy loading is automatically disabled, andfetchpriority="high"is added to the image.You should use the
priorityproperty on any image detected as the Largest Contentful Paint (LCP) element. It may be appropriate to have multiple priority images, as different images may be the LCP element for different viewport sizes. Should only be used when the image is visible above the fold.sizes: If you're using this prop, you can avoid requestingsizesin theresponsiveImagequery.srcSetCandidates: If you're not requestingsrcSetin theresponsiveImagequery,srcSetCandidateswill be used to generate the differentsrcsetcandidate strings at various widths. Default candidates are:[0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4].