Skip to content
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

errorOnFail option if you don’t want to fail the entire build if one image has an error. #225

Open
zachleat opened this issue Apr 22, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@zachleat
Copy link
Member

Default to true.

@zachleat zachleat added the enhancement New feature or request label Apr 22, 2024
@zachleat
Copy link
Member Author

Via the image transform maybe an eleventy:optional attribute that will remove remote images that fail.

The impetus use case here is build-time opencollective avatar images on 11ty.dev

@eaton
Copy link

eaton commented Aug 9, 2024

This has been important for a project with many old image references pointing out to external sites. eleventy-img handles 404s pretty gracefully, but on occasion encounters references to domains that won't even resolve — bringing the whole build down. Being able to sidestep that issue and proceed with the build with be a huge benefit.

@lsolesen
Copy link

Is it possible to do this yet? I am moving some sites to 11ty, and would be great if they were able to build without having to fix the 404 images first. Could it fail with a notice instead? I am using the imageTransformPlugin:

 // Automatically improve images
  eleventyConfig.addPlugin(eleventyImageTransformPlugin, {
    // which file extensions to process
    extensions: 'html',
    // optional, output image formats
    formats: ['jpg', 'png', 'webp'],
    // optional, output image widths
    widths: ['auto', 400, 800],
    // optional, attributes assigned on <img> override these values.
    defaultAttributes: {
      loading: 'lazy',
      sizes: '100vw',
      decoding: 'async',
    },
  });

But it fails hard on 404 images:

[11ty] Problem writing Eleventy templates:
[11ty] 1. Having trouble writing to "./_site/discgolf-apps/index.html" from "./_posts/2022-07-28-discgolf-apps.md" (via EleventyTemplateError)
[11ty] 2. Transform `@11ty/eleventy/html-transformer` encountered an error when transforming ./_posts/2022-07-28-discgolf-apps.md. (via EleventyTransformError)
[11ty] 3. Bad response for https://images.com/404.jpg (404): Not Found
[11ty] 
[11ty] Original error stack trace: Error: Bad response for https://tjing.se/img/LiveScoring%E2%80%93Expanded_New.a386af0a.png (404): Not Found
[11ty]     at RemoteAssetCache.fetch (/home/lsolesen/projects/discer-dk-jekyll/node_modules/@11ty/eleventy-fetch/src/RemoteAssetCache.js:69:11)
[11ty]     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[11ty]     at async run (/home/lsolesen/projects/discer-dk-jekyll/node_modules/p-queue/dist/index.js:163:29)

@zachleat zachleat added this to the Eleventy Image v6.0.0 milestone Nov 16, 2024
@zachleat
Copy link
Member Author

Milestoning to 6.0.0

@zachleat
Copy link
Member Author

Important reference to #252 which unlocks the use of native fetch and AbortSignal for timeouts https://github.com/11ty/eleventy-fetch/releases/tag/v5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants