[RFC] Static Loader for next/image #26850
darshkpatel
started this conversation in
Ideas
Replies: 2 comments
-
I don't think "static" is the best term to use here since it has other meanings. This is more like "pass-through". That being said, this could harm performance because we don't know if the upstream image host supports resizing images. |
Beta Was this translation helpful? Give feedback.
0 replies
-
PR #26998 just landed and will be available in the next canary either today or tomorrow |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
A loader called
static
for next/image which lets one simply load the URL passed into the src parameter, it can also alternatively be augmented using a custom loader.Background
Ref: #21079 , #19612
A lot of users are trying to use next/image with the
next export
command while not using a third-party service for loading images.Also, custom loaders were not recognized during
next export
, users were using a 'hack' #21079 (comment) by using the imgix loader with their own URLs, using the static loader would allow users to use custom url's without using such hacks.Implementation
A staticloader function which simply returns the URL mentioned in the src parameter
Breaking changes?
None.
Usage
Image Component
<Image alt="MyImage" src={'https://myassetserver/image.png'} width={700} />
Downsides
If someone wants to use a common custom loader across all image components one would have to define the loader prop everywhere,
Implementing support for recognizing functions passed in directly from next config can be more ideal but that'd require quiet a few changes in the existing way the loaders configuration is implemented.
Proposed Implementation
#26847
Beta Was this translation helpful? Give feedback.
All reactions