next-sanity-image icon indicating copy to clipboard operation
next-sanity-image copied to clipboard

Send "original" URL as src attribute

Open andershagbard opened this issue 1 year ago • 3 comments

Resolves https://github.com/lorenzodejong/next-sanity-image/issues/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

andershagbard avatar Jul 16 '24 14:07 andershagbard

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.

lorenzodejong avatar Jul 23 '24 19:07 lorenzodejong

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 avatar Jul 24 '24 10:07 andershagbard

@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.

andershagbard avatar Sep 30 '24 11:09 andershagbard