Merge pull request #521 from ejulia/fix-image-position-prop-override

Fix the override of the Image objectPosition attribute
This commit is contained in:
André B
2024-10-04 02:50:46 -04:00
committed by GitHub

View File

@@ -21,6 +21,7 @@ export interface ImageProps extends Omit<HTMLAttributes<'img'>, 'src'> {
layout?: Layout; layout?: Layout;
widths?: number[] | null; widths?: number[] | null;
aspectRatio?: string | number | null; aspectRatio?: string | number | null;
objectPosition?: string;
} }
export type ImagesOptimizer = ( export type ImagesOptimizer = (
@@ -259,7 +260,7 @@ export const unpicOptimizer: ImagesOptimizer = async (image, breakpoints, width,
/* ** */ /* ** */
export async function getImagesOptimized( export async function getImagesOptimized(
image: ImageMetadata | string, image: ImageMetadata | string,
{ src: _, width, height, sizes, aspectRatio, widths, layout = 'constrained', style = '', ...rest }: ImageProps, { src: _, width, height, sizes, aspectRatio, objectPosition, widths, layout = 'constrained', style = '', ...rest }: ImageProps,
transform: ImagesOptimizer = () => Promise.resolve([]) transform: ImagesOptimizer = () => Promise.resolve([])
): Promise<{ src: string; attributes: HTMLAttributes<'img'> }> { ): Promise<{ src: string; attributes: HTMLAttributes<'img'> }> {
if (typeof image !== 'string') { if (typeof image !== 'string') {
@@ -315,6 +316,7 @@ export async function getImagesOptimized(
width: width, width: width,
height: height, height: height,
aspectRatio: aspectRatio, aspectRatio: aspectRatio,
objectPosition: objectPosition,
layout: layout, layout: layout,
})}${style ?? ''}`, })}${style ?? ''}`,
...rest, ...rest,