diff --git a/src/modules/image/index.ts b/src/modules/image/index.ts index 9ec579ec10b..cce875ba5f5 100644 --- a/src/modules/image/index.ts +++ b/src/modules/image/index.ts @@ -199,12 +199,12 @@ export class ImageModule { * @param options.blur Whether the image should be blurred. Defaults to `false`. * * @example - * faker.image.urlPicsumPhotos() // 'https://picsum.photos/id/241/640/480' - * faker.image.urlPicsumPhotos({ width: 128 }) // 'https://picsum.photos/id/241/128/480' - * faker.image.urlPicsumPhotos({ height: 128 }) // 'https://picsum.photos/id/241/640/128' - * faker.image.urlPicsumPhotos({ grayscale: true }) // 'https://picsum.photos/id/241/640/480?grayscale' - * faker.image.urlPicsumPhotos({ blur: 4 }) // 'https://picsum.photos/id/241/640/480?blur=4' - * faker.image.urlPicsumPhotos({ blur: 4, grayscale: true }) // 'https://picsum.photos/id/241/640/480?grayscale&blur=4' + * faker.image.urlPicsumPhotos() // 'https://picsum.photos/seed/NWbJM2B/640/480' + * faker.image.urlPicsumPhotos({ width: 128 }) // 'https://picsum.photos/seed/NWbJM2B/128/480' + * faker.image.urlPicsumPhotos({ height: 128 }) // 'https://picsum.photos/seed/NWbJM2B/640/128' + * faker.image.urlPicsumPhotos({ grayscale: true }) // 'https://picsum.photos/seed/NWbJM2B/640/480?grayscale' + * faker.image.urlPicsumPhotos({ blur: 4 }) // 'https://picsum.photos/seed/NWbJM2B/640/480?blur=4' + * faker.image.urlPicsumPhotos({ blur: 4, grayscale: true }) // 'https://picsum.photos/seed/NWbJM2B/640/480?grayscale&blur=4' * * @since 8.0.0 */ @@ -238,9 +238,9 @@ export class ImageModule { ): string { const { width = 640, height = 480, grayscale = false, blur } = options; - let url = `https://picsum.photos/id/${this.faker.number.int( - 1000 - )}/${width}/${height}`; + let url = `https://picsum.photos/seed/${this.faker.string.alphanumeric({ + length: { min: 5, max: 10 }, + })}/${width}/${height}`; const hasValidGrayscale = grayscale === true; const hasValidBlur = typeof blur === 'number' && blur >= 1 && blur <= 10; diff --git a/test/__snapshots__/image.spec.ts.snap b/test/__snapshots__/image.spec.ts.snap index 77b5a029739..676e2975eef 100644 --- a/test/__snapshots__/image.spec.ts.snap +++ b/test/__snapshots__/image.spec.ts.snap @@ -26,19 +26,19 @@ exports[`image > 42 > urlLoremFlickr > with width 1`] = `"https://loremflickr.co exports[`image > 42 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=3373557438480384"`; -exports[`image > 42 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/374/640/480"`; +exports[`image > 42 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/seed/NWbJMBB/640/480"`; -exports[`image > 42 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/id/374/128/128?grayscale&blur=4"`; +exports[`image > 42 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/seed/NWbJMBB/128/128?grayscale&blur=4"`; -exports[`image > 42 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/id/374/640/480?blur=6"`; +exports[`image > 42 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/seed/NWbJMBB/640/480?blur=6"`; -exports[`image > 42 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/id/374/640/480?grayscale&blur=3"`; +exports[`image > 42 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/seed/NWbJMBB/640/480?grayscale&blur=3"`; -exports[`image > 42 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/id/374/640/128"`; +exports[`image > 42 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/seed/NWbJMBB/640/128"`; -exports[`image > 42 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/id/374/128/480"`; +exports[`image > 42 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/seed/NWbJMBB/128/480"`; -exports[`image > 42 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/id/374/128/128"`; +exports[`image > 42 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/seed/NWbJMBB/128/128"`; exports[`image > 42 > urlPlaceholder > noArgs 1`] = `"https://via.placeholder.com/1498x3186/e4abdd/39321a.webp?text=veniam%20unde%20fugit"`; @@ -66,13 +66,13 @@ exports[`image > 1211 > avatarGitHub 1`] = `"https://avatars.githubusercontent.c exports[`image > 1211 > avatarLegacy 1`] = `"https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/1160.jpg"`; -exports[`image > 1211 > url > noArgs 1`] = `"https://picsum.photos/id/459/640/480"`; +exports[`image > 1211 > url > noArgs 1`] = `"https://picsum.photos/seed/TMd8Z2F/640/480"`; -exports[`image > 1211 > url > with height 1`] = `"https://picsum.photos/id/459/640/128"`; +exports[`image > 1211 > url > with height 1`] = `"https://picsum.photos/seed/TMd8Z2F/640/128"`; -exports[`image > 1211 > url > with width 1`] = `"https://picsum.photos/id/459/128/480"`; +exports[`image > 1211 > url > with width 1`] = `"https://picsum.photos/seed/TMd8Z2F/128/480"`; -exports[`image > 1211 > url > with width and height 1`] = `"https://picsum.photos/id/459/128/128"`; +exports[`image > 1211 > url > with width and height 1`] = `"https://picsum.photos/seed/TMd8Z2F/128/128"`; exports[`image > 1211 > urlLoremFlickr > noArgs 1`] = `"https://loremflickr.com/640/480?lock=8363366036799488"`; @@ -86,19 +86,19 @@ exports[`image > 1211 > urlLoremFlickr > with width 1`] = `"https://loremflickr. exports[`image > 1211 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=8363366036799488"`; -exports[`image > 1211 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/929/640/480"`; +exports[`image > 1211 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/640/480"`; -exports[`image > 1211 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/id/929/128/128?grayscale&blur=4"`; +exports[`image > 1211 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/128/128?grayscale&blur=4"`; -exports[`image > 1211 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/id/929/640/480?blur=6"`; +exports[`image > 1211 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/640/480?blur=6"`; -exports[`image > 1211 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/id/929/640/480?grayscale&blur=3"`; +exports[`image > 1211 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/640/480?grayscale&blur=3"`; -exports[`image > 1211 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/id/929/640/128"`; +exports[`image > 1211 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/640/128"`; -exports[`image > 1211 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/id/929/128/480"`; +exports[`image > 1211 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/128/480"`; -exports[`image > 1211 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/id/929/128/128"`; +exports[`image > 1211 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/seed/sTMd8Z2F9G/128/128"`; exports[`image > 1211 > urlPlaceholder > noArgs 1`] = `"https://via.placeholder.com/3714x1836/db42f0/e3f4a9.jpeg?text=consequuntur%20quidem%20nobis"`; @@ -146,19 +146,19 @@ exports[`image > 1337 > urlLoremFlickr > with width 1`] = `"https://loremflickr. exports[`image > 1337 > urlLoremFlickr > with width and height 1`] = `"https://loremflickr.com/128/128?lock=2360108468142080"`; -exports[`image > 1337 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/id/262/640/480"`; +exports[`image > 1337 > urlPicsumPhotos > noArgs 1`] = `"https://picsum.photos/seed/y9dhxs/640/480"`; -exports[`image > 1337 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/id/262/128/128?grayscale&blur=4"`; +exports[`image > 1337 > urlPicsumPhotos > with all options 1`] = `"https://picsum.photos/seed/y9dhxs/128/128?grayscale&blur=4"`; -exports[`image > 1337 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/id/262/640/480?blur=6"`; +exports[`image > 1337 > urlPicsumPhotos > with blur 1`] = `"https://picsum.photos/seed/y9dhxs/640/480?blur=6"`; -exports[`image > 1337 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/id/262/640/480?grayscale&blur=3"`; +exports[`image > 1337 > urlPicsumPhotos > with blur and grayscale 1`] = `"https://picsum.photos/seed/y9dhxs/640/480?grayscale&blur=3"`; -exports[`image > 1337 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/id/262/640/128"`; +exports[`image > 1337 > urlPicsumPhotos > with height 1`] = `"https://picsum.photos/seed/y9dhxs/640/128"`; -exports[`image > 1337 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/id/262/128/480"`; +exports[`image > 1337 > urlPicsumPhotos > with width 1`] = `"https://picsum.photos/seed/y9dhxs/128/480"`; -exports[`image > 1337 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/id/262/128/128"`; +exports[`image > 1337 > urlPicsumPhotos > with width and height 1`] = `"https://picsum.photos/seed/y9dhxs/128/128"`; exports[`image > 1337 > urlPlaceholder > noArgs 1`] = `"https://via.placeholder.com/1048x2242/346ba0/75bd57.webp?text=tempora%20tempore%20aliquam"`; diff --git a/test/image.spec.ts b/test/image.spec.ts index a0a6d4eff70..612766914b2 100644 --- a/test/image.spec.ts +++ b/test/image.spec.ts @@ -455,7 +455,7 @@ describe('image', () => { expect(imageUrl).toBeTypeOf('string'); expect(imageUrl).toMatch( - /^https\:\/\/picsum\.photos\/id\/\d+\/\d+\/\d+$/ + /^https\:\/\/picsum\.photos\/seed\/[0-9a-zA-Z]+\/\d+\/\d+$/ ); }); });