Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce the props passed in for the image #117

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Changes from all commits
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
6 changes: 3 additions & 3 deletions components/Image/Image.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ function wpImageLoader ( { quality, src, width }: ImageLoaderProps ): string {
}

export default function Image ( props: Props ) {
const { originalHeight, originalWidth, ...imageProps } = props;
const { originalHeight, originalWidth } = props;
const height = props.height || originalHeight;
const width = props.width || originalWidth;

if ( VipConfig.images.useHtmlTag && props.srcset ) {
return (
// eslint-disable-next-line @next/next/no-img-element
<img
{...imageProps}
alt={props.alt}
srcSet={props.srcset}
/>
Expand All @@ -47,7 +46,8 @@ export default function Image ( props: Props ) {
return (
<NextImage
loader={loader}
{...imageProps}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ingeniumed Minor, but I noticed that we use the NextImage-specific property fill here on line 45:

<Image
alt={altText}
className={styles.image}
fill={true}
src={sourceUrl}
/>

which will get dropped by the changes. Is there a way to change things so Image still properly passes inner properties to NextImage?

alt={props.alt}
src={props.src}
height={height}
width={width}
/>
Expand Down