-
Notifications
You must be signed in to change notification settings - Fork 66
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
Add a possibility to pass a fallback image url to the options #59
Comments
For those who could face a similar problem, I solved it by creating a node middleware that looks if there is an attempt to fetch something using the import { existsSync } from 'fs';
export default function (req, res, next) {
if (
req.url.includes('/_ipx') &&
!existsSync('static/img/path.png') // you can parse the req.url to get the path of the image of interest
) {
res.redirect('path/to/the/placeholder.png');
} else {
next();
}
} Is it worth adding this to the docs to showcase to others how it can be solved? |
I have another issue where the user could upload a corrupted jpg file, IPX will throw an error at this case, since it can't parse the meta data to optimize the image. Can I fallback to the original image in this case? Essentially I need to hook into the response of an ipx call in my nuxt-app. If the ipx call fails, i first want to try to get the original image and if that fails too, send an error. Is that possible? |
In my project, I need to get images via ipx, and if there is no such image, I would love to get some placeholder that I would have specified in options. So, is there any way to add such a thing, so the initialization would look like
Or is there already a way I could handle such 404 errors myself?
The text was updated successfully, but these errors were encountered: