Niels-IO / next-image-export-optimizer

Use Next.js advanced <Image/> component with the static export functionality. Optimizes all static images in an additional step after the Next.js static export.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Download remote images error at specific number of images

thuatz opened this issue · comments

commented

View: src/utils/downloadImagesInBatches.ts
Function: downloadImagesInBatches

const batches = Math.ceil(imagesURLs.length / batchSize); // determine the number of batches

for (let i = 0; i < batches; i++) {

    const start = i * batchSize; // calculate the start index of the batch

    const end = Math.min(imagesURLs.length, start + batchSize); // calculate the end index of the batch

    const batchURLs = imagesURLs.slice(start, end); // slice the URLs for the current batch

    const batchFileNames = imageFileNames.slice(start, end); // slice the file names for the current batch

    if (batchFileNames[i].fullPath === undefined) {`

If 231 images, we have 12 batches. Then last patch has only 11 images (index from 0 to 10). Then it throws error at i = 11

commented

Hi @thuatz,
Thanks for the error report. I opened a PR for a fix