Skip to content

Conversation

andershagbard
Copy link
Contributor

Resolves #50

Next.js sends an error if src is the same as the optimized image.

In this case, we sent the optimized src attribute back to the getImgProps function

@lorenzodejong
Copy link
Owner

lorenzodejong commented Jul 23, 2024

I understand the fix you're trying to implement here, however this will impact some of the flexibility that the library provides. By defining a base image without any customization options from the imageBuilder option, you remove the capability of cropping/scaling and other image transformations.

This will not be an issue from any of the images from the srcset attribute, however will impact the src image as a fallback.

Could you elaborate on the specific way this fixes the issue in the library? If we know the root cause of the issue, we may be able to come up with a fix which doesn't impact the customizability of the library.

@andershagbard
Copy link
Contributor Author

The passed src seems to just be the original resource for the URL.

The src attribute passed to the img tag is still optimized. Check this line: https://github.com/vercel/next.js/blob/00ed837bb4b71ce0c30256e4d07638225b31a7e5/packages/next/src/shared/lib/get-img-props.ts#L231

@andershagbard
Copy link
Contributor Author

@lorenzodejong I've updated the tests, but I am unsure if they are actually worth having anymore. It's the loader function result which should be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Image with src has a "loader" property that does not implement width. Please implement it or use the "unoptimized" property instead.

2 participants