-
Notifications
You must be signed in to change notification settings - Fork 27k
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
[WIP] Next.js Image Component #18122
Comments
I could lend a hand with these if needed. |
|
Given the current |
Great work on this, I've been following the RFC, canary developments and the above pull requests. In the RFC it was mentioned that there should be support for multiple CDNs at the same time. We're modelling the way we save user-generated images now and notice that just saving the absolute url might not be enough, since then we can't make proper use of the next/image component. Now we're thinking of saving the root url, relative path, dimensions and source / provider (e.g. imgix / cloudinary). According to the docs, loaders should be defined like this: module.exports = {
images: {
loader: 'imgix',
path: 'https://example.com/myaccount/',
},
} Now what if we are initially using cloudinary, later want to move to imgix or our own solution? The RFC mentioned the following:
I don't see any (work in process) PR's open for this functionality and it's not clear on how to implement this yet, is someone working on this and is this planned for the coming release? |
Previously, vector images like svg were being converted to webp and resized. However, vector images already handle any size so we can bypass the same we do for animated images. Related to #18122
For many users refactoring from `<img>` to `<Image>`, we can often support their properties as-is. The exception was width/height. This PR allows the `<Image>` component to accept strings for `width` and `height` just like `<img>`. Related to #18122
Support for it was removed for the initial release given that it adds significant complexity in both implementation and configuration. It also caused more code than necessary to be shipped to the browser. We'll address it later if there's enough need for it. In general it's uncommon to be hosting on both imgix and cloudinary at the same time. |
We currently pass through `images` whenever its defined, but this is enabling Image Optimization in the Proxy for every Next.js project. Instead, we should check to see if the default loader is used (the same use for `next dev`) as a signal to enable this feature in the deployment. Related to vercel/next.js#18122
Solves on of the issues in #18122
We currently always accept requests to the new `/_next/image` endpoint, even when it should not be used. Instead, we should check to see if the default loader is used as a signal to enable this API. Other loaders (such as cloudinary) will not go through the Next.js API so there is no need to expose this, instead we 404. - Analogous to vercel/vercel#5321 - Related to #18122
I am excited to see the new Image component. I would like to know if there will be an example how to deal with an Image which is part of a 2 column flexrow element (lets say on a grid with 50% or 30% width) on tablet/desktop. But on a mobile its 100% width. Is there any example in place how that should be done? |
…ossible image (#18236) There was a bug when the user defines a width on the Image component, but a larger size image is requested. This is because the browser uses the `srcset` to decide which image size to request and we had the srcset basically hardcoded. This PR fixes the behavior so that the `srcset` will never be larger than the `width` defined on the component. It also fixes a bug where the preload srcset did not match the img srcset. - Related to #18147 - Related to #18122
This adds checks to ensure that less than 50 domain and size items are configured and no sizes are less than 0 or greater than 10,000 x-ref: #18122 Co-authored-by: Steven <[email protected]>
This separates the `next.config.js` property `images.sizes` into to properties: `images.deviceSizes` and `images.iconSizes`. The purpose is for images that are not intended to take up the majority of the viewport. Related to #18122
Does this comment include removing support for a single, custom service loader? In our case, we have an in-house image service that doesn't conform to the path patterns for any of the options I saw in the documentation (default, imgix, cloudinary, akamai). Is there a way to disable the loader and simply pass the path through to the |
Apologies if this is the wrong place to ask, but it doesn't seem like the Image component currently supports optimizing images during the build phase for completely static sites. Is this something that has been considered? |
So excited about this component and all the work around it. Thanks to all involved! 🐛 Hope this isn't the wrong place to mention this, but I just noticed when testing the Image component that |
Here next.js/packages/next/client/image.tsx Lines 383 to 459 in 5d7f7a4
I feel like these functions are simple. I want to create a custom Loader func which receives P.S.
Edit
|
The It's best to use |
@colepeters Having trouble with this. What does your Edit: forgot to add |
@styfle Just to be clear, the @AlexandraKlein Here's what I've got:
What I'm doing is prepending |
With Contentful, when the image src prop changes within the same react component on route change, Image component isn't swapping out old image for new. @colepeters have you seen this? Takes a browser reload to see new image. Though adding a key prop triggers rerender populating correct image. |
@AlexandraKlein Sounds like another case of #18369 |
I'm wondering if there's plans for a Contentful loader? Contentful has an Image API similar to Imgix or Cloudinary, wondering it makes sense to use that directly? |
I'm wondering if there are plans to add support for custom loaders? Maybe, for example, user could pass a Anyway, are there plans for Cloudflire Resize loader? I think I could contribute... |
This works fine locally for me but urls give me 400 errors in production with Source url with 400 error: Source url locally with no error: |
PR in progress: #19117 |
We currently pass through `images` whenever its defined, but this is enabling Image Optimization in the Proxy for every Next.js project. Instead, we should check to see if the default loader is used (the same use for `next dev`) as a signal to enable this feature in the deployment. Related to vercel/next.js#18122
I made a component layer above next-image with Image as the naming component, and have set a function with autocompleting asset location if only filename is provided and am currently getting an error of "using relative image it must start with a leading slash "/"" Is there a way to turn this off? The app won't compile without it. Also, reason for the function is to shorten the length of the Image component by removing paths |
This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you. |
Keeping track of the feedback so far:
<img>
with empty or not foundsrc
iconflexbox
are not lazy loaded (@timneutkens)width
andheight
are missing andunsized
is not set (@styfle)lazy=true
toloading=lazy
to match web standard (@styfle)next/image
and automatic image optimization (@styfle)url
parameter (@ijjk)w
param for old browsers like IE that dont supportsrcset
(@styfle)width
andheight
attributes (use parseInt and error) (@styfle)domains
(@ijjk)images.domains
andimages.sizes
to 50, maximum value of size to 10000@vercel/next
whenloader=default
(@styfle)loader=default
(@styfle)srcset
to ensure the component'swidth
is the largest possible image #18236 Fixsrcset
to ensure the componentswidth
is the largest possible image (@styfle)deviceSizes
andiconSizes
#18267 SeparatedeviceSizes
andiconsSizes
(@styfle)quality
attribute should allow number or string likewidth
(@ykzts)next dev
for/_next/image/
to/_next/image
(@styfle)next dev
and Vercel deployments/next/conf
) (@leerob)@geist/image/new
)The text was updated successfully, but these errors were encountered: