Comments (4)
Hi @augustblack,
Thanks for the kind words!
So if you want one folder with all images inside, then use statically imported images. All optimized images will be placed in a folder called nextImageExportOptimizer at the root level of your export folder.
Duplicated folders could exist if you store your statically imported image in the same place, next-image-export-optimizer is looking for images (nextImageExportOptimizer_imageFolderPath).
In the dev tools of Chrome, you should see the generated srcset like this:
If that is not the case, then something else might be wrong.
You could only work with find and replace if you have a completely static app. As soon as React will be hydrated, then the URL will change again to the one this module is generating.
The solution is quite straightforward. You could add the absolute URL for the images to the loader function. Part of how it is currently done is shown in this snippet:
let generatedImageURL = `${
isStaticImage ? "" : correctedPath
}${exportFolderName}/${filename}-opt-${width}.${processedExtension.toUpperCase()}`;
// if the generatedImageURL is not starting with a slash, then we add one
if (generatedImageURL.charAt(0) !== "/") {
generatedImageURL = "/" + generatedImageURL;
}
return generatedImageURL;
};
You would prepend the string "generatedImageURL" with your absolute URL. This is also in agreement with the official Next.js docs: https://nextjs.org/docs/api-reference/next/image#loader-configuration
As this is a special use case, I recommend you fork your own version of this module.
from next-image-export-optimizer.
Hi @Niels-IO
Thanks for the reply. I'm still trying to figure out what is going on.
I'm observing some strange behavior on the export in general. In my setup, I have removed all images from the ./public
folder. Any image src on <ExportedImage />
is statically imported. I am exporting with next build && next export && next-image-export-optimizer
and default settings
First, it appears with a simple export, the blur images are not getting used. The images load with a blank first and then come in with the full image (even though placeholder="blur"
is set and was working in the past versions).
Second, it seems as if the first url that is loaded is /_next/static/media/<filename>
and not /nextImageExportOptimizer/<filename>
Third, when I run a simple static html server (eg. python3 -m http.server
) on the exported output, it seems as if either this module or next.js (not sure which) is prepending a full http://hostname:port
to the URL - instead of src="/filename"
it is setting src="http://localhost:8000/filename"
Ideally, the image src would only have a relative path to the hostname and not include the hostname in the URL.
Do you happen to know why /_next/static/media/<filename>
is created at all?
from next-image-export-optimizer.
First, it appears with a simple export, the blur images are not getting used. The images load with a blank first and then come in with the full image (even though placeholder="blur" is set and was working in the past versions).
Are you using Firefox? Blurry placeholders currently do not work in Firefox, unfortunately. The background image does not get displayed.
Second, it seems as if the first url that is loaded is /_next/static/media/ and not /nextImageExportOptimizer/
This is only the case when the optimized images cannot be found, and the /_next/static/media/ is then used as a fallback. Could you please check whether the folder nextImageExportOptimizer was generated in your public folder and contains the optimized images?
Third, when I run a simple static html server (eg. python3 -m http.server) on the exported output, it seems as if either this module or next.js (not sure which) is prepending a full http://hostname:port to the URL - instead of src="/filename" it is setting src="http://localhost:8000/filename" Ideally, the image src would only have a relative path to the hostname and not include the hostname in the URL.
This is not done purposely by this module. I guess that it is also happening in the standard Next.js image component.
Do you happen to know why /_next/static/media/ is created at all?
This is where Next.js stores the optimized statically imported images.
from next-image-export-optimizer.
Hi,
I'm not using firefox and was having issues with the blur in chrome.
The nextImageExportOptimizer folder was created and all the files are there.
Ultimately, I did a little digging and decided to use the base Image module of next but set a custom loader.
That doesn't auto-generate the images like this module does, but was more straightforward for my use case.
thanks for the attention and for this software - I still use it in other cases.
from next-image-export-optimizer.
Related Issues (20)
- Using remote SVGs HOT 1
- Feature request: Don't download again for X days HOT 4
- process.env.nextImageExportOptimizer_storePicturesInWEBP assumed to be boolean HOT 1
- Next.js 14 dev mode error HOT 2
- Images that dont have predefined height HOT 8
- SVG optimization with tools like svgo HOT 2
- Can't optimize two different path HOT 1
- unexpected property: transpilePackages HOT 4
- Srcset not created for Static Images HOT 28
- Output folder not being created on build. HOT 12
- Add support for Picture element HOT 1
- Issue with query string get params HOT 2
- Could not load sharp module error HOT 2
- Export utilities from ExportedImage component HOT 1
- Allow setting location of the hashes.json and optimized images
- Add `unoptimized` configuration option
- Adding custom options when fetching remote images HOT 4
- Doesn't work on next 14.1 HOT 2
- Remote image download error: `ENAMETOOLONG: name too long` HOT 3
- Images exporting too all sizes but all rendering at full size HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from next-image-export-optimizer.