DMarby / picsum-photos

Lorem Ipsum... but for photos.

Home Page:https://picsum.photos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Filling holes in image IDs

pzich opened this issue · comments

While building some prototypes with an array of images, I found that some some IDs seem to return a 404 with Image does not exist. As example, this code…

new Array(20).fill().forEach((_, i) => {
  const img = new Image()
  img.width = 100
  img.height = 100
  img.src = `https://picsum.photos/id/${i + 740}/100/100`
  document.body.appendChild(img)
})

…results in this set of mostly broken images.

740 - 759

To check which ones are missing/broken, I created this tester page and found that the following IDs resulted in errors:

86, 97, 105, 138, 148, 150, 205, 207, 224, 226, 245, 246, 262, 285, 286, 298, 303, 332, 333, 346, 359, 394, 414, 422, 438, 462, 463, 470, 489, 540, 561, 578, 587, 589, 592, 595, 597, 601, 624, 632, 636, 644, 647, 673, 697, 706, 707, 708, 709, 710, 711, 712, 713, 714, 720, 725, 734, 745, 746, 747, 748, 750, 749, 751, 753, 752, 754, 759, 761, 762, 763, 771, 792, 801, 812, 843, 850, 854, 895, 897, 899, 917, 920, 934, 956, 963, 968, 1007, 1017

I'm not quite sure what causes these images to error, but I was wondering if it'd be possible to either squash the list down so all of the IDs are sequential or (in case people are relying on specific IDs) replace them with other working images? It would simplify prototypes that need to show a range of images and eliminate needing special code to check if the images error out and need to use a different ID.

Hi,

Thank you for filing an issue! The IDs of existing images can't be changed for backwards compatibility reasons, and we currently have no plans to fill the gaps, you shouldn't be relying on them being sequential.

If you want a static set of images rather then random from just passing the dimensions, you can paginate use the list endpoint to get valid IDs, or use the /seed endpoint.

Duplicate of #102, #83