-
Notifications
You must be signed in to change notification settings - Fork 555
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
NextJS Image issue #377
Comments
Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can. |
Hi! Faced a similar problem in next js. The inclusion of "includeQueryParams: true" in the list of options helped me solve it. |
That works! I tested and can confirm. Add "includeQueryParams: true" to toPng's options solves it. |
Can also confirm that this works 🎉 |
OMG I was stuck on this for hours. This is solution! It seems nextjs relies on the query parameters to get the right image. Thank you so much!
|
yep that was the fix! |
Expected Behavior
I should be able to convert as many HTML elements with < Image /> inside as I want, and get dataURLs with the correct inner < Image /> alongside anything else in the same element.
What happens instead
Instead, toPng returns the dataURL for the first image within the Div that was converted to dataURL and downloaded. If an image is loaded through a regular < img/> or as a background-image, there is no problem. But if it is loaded with a < Image /> (from Next's "next/image"), then the resulting dataURL will always use the< Image /> of the first Div element that was converted toPng.
Possible Solution
The workaround I am going with currently is to load the image as a < img /> instead of using Next's < Image />, but it's obviously a suboptimal solution.
I considered that maybe some caching issue was causing this, but not that I could find with just a quick investigation.
Steps To Reproduce
given 2 images served through NextJS's "< Image /> ("next/image")
-> get dataURL through toPng and download image .1
-> get dataURL through toPng and download image .2
The two dataURLs returned should be the same, provided nothing else within the element, that is toPng'd, differs.
Additional Context
My element is as follows:
A page has multiple of the above element, which I want to toPng and download.
The .blurredImg is what is not being outputted correctly through toPng with the 2nd+ runs
The parent element has a before pseudo class which adds a border of sorts.
Your Environment
"html-to-image": "^1.11.11",
"next": "13.1.6",
"react": "18.2.0",
"react-dom": "18.2.0",
Browser: chrome (latest)
The text was updated successfully, but these errors were encountered: