Skip to content

Commit

Permalink
Merge pull request #521 from ejulia/fix-image-position-prop-override
Browse files Browse the repository at this point in the history
Fix the override of the Image objectPosition attribute
  • Loading branch information
prototypa authored Oct 4, 2024
2 parents d942f2b + e1c32b5 commit d903e6c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/utils/images-optimization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ImageProps extends Omit<HTMLAttributes<'img'>, 'src'> {
layout?: Layout;
widths?: number[] | null;
aspectRatio?: string | number | null;
objectPosition?: string;
}

export type ImagesOptimizer = (
Expand Down Expand Up @@ -259,7 +260,7 @@ export const unpicOptimizer: ImagesOptimizer = async (image, breakpoints, width,
/* ** */
export async function getImagesOptimized(
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([])
): Promise<{ src: string; attributes: HTMLAttributes<'img'> }> {
if (typeof image !== 'string') {
Expand Down Expand Up @@ -315,6 +316,7 @@ export async function getImagesOptimized(
width: width,
height: height,
aspectRatio: aspectRatio,
objectPosition: objectPosition,
layout: layout,
})}${style ?? ''}`,
...rest,
Expand Down

0 comments on commit d903e6c

Please sign in to comment.