Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface GatsbyImageProps
alt: string
as?: ElementType
className?: string
class?: string
imgClassName?: string
image: IGatsbyImageData
imgStyle?: CSSProperties
Expand Down Expand Up @@ -68,6 +69,10 @@ export const GatsbyImageHydrator: FunctionComponent<GatsbyImageProps> = function
}
return null
}
if (`class` in props) {
className = props.class
delete props.class
}
const { width, height, layout, images } = image

const root = useRef<HTMLElement>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,16 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI
console.warn(`[gatsby-plugin-image] Missing image prop`)
return null
}
if (`class` in props) {
className = props.class
delete props.class
}
imgStyle = {
objectFit,
objectPosition,
backgroundColor,
...imgStyle,
}

const {
width,
Expand Down Expand Up @@ -97,6 +107,8 @@ export const GatsbyImage: FunctionComponent<GatsbyImageProps> = function GatsbyI
<MainImage
data-gatsby-image-ssr=""
sizes={sizes}
className={imgClassName}
style={imgStyle}
{...(props as Omit<MainImageProps, "images" | "fallback">)}
// When eager is set we want to start the isLoading state on true (we want to load the img without react)
{...getMainProps(loading === `eager`, false, cleanedImages, loading)}
Expand Down