Unverified Commit 12eb8122 authored by Alex Castle's avatar Alex Castle Committed by GitHub

Add data-nimg attribute to image component (#27899)

This PR adds a single data attribute to the image element generated by the image component `data-nimg`) which just serves to signal that this image element is from the component. Currently it's hard to quickly/programmatically determine with certainty whether an image is from the component or not, so this change should make it easier for us to diagnose and improve performance issues related to the image component.
parent b4be678e
...@@ -600,6 +600,7 @@ export default function Image({ ...@@ -600,6 +600,7 @@ export default function Image({
loader, loader,
})} })}
decoding="async" decoding="async"
data-nimg
style={imgStyle} style={imgStyle}
className={className} className={className}
/> />
...@@ -609,6 +610,7 @@ export default function Image({ ...@@ -609,6 +610,7 @@ export default function Image({
{...rest} {...rest}
{...imgAttributes} {...imgAttributes}
decoding="async" decoding="async"
data-nimg
className={className} className={className}
ref={(img) => { ref={(img) => {
setRef(img) setRef(img)
...@@ -633,9 +635,9 @@ export default function Image({ ...@@ -633,9 +635,9 @@ export default function Image({
rel="preload" rel="preload"
as="image" as="image"
href={imgAttributes.srcSet ? undefined : imgAttributes.src} href={imgAttributes.srcSet ? undefined : imgAttributes.src}
// @ts-ignore: imagesrcset is not yet in the link element type // @ts-ignore: imagesrcset is not yet in the link element type.
imagesrcset={imgAttributes.srcSet} imagesrcset={imgAttributes.srcSet}
// @ts-ignore: imagesizes is not yet in the link element type // @ts-ignore: imagesizes is not yet in the link element type.
imagesizes={imgAttributes.sizes} imagesizes={imgAttributes.sizes}
></link> ></link>
</Head> </Head>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment