You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -11,7 +12,7 @@ import { ModuleBase } from '../../internal/module-base';
11
12
*
12
13
* For a random placeholder image containing only solid color and text, use [`urlPlaceholder()`](https://fakerjs.dev/api/image.html#urlplaceholder) (uses a third-party service) or [`dataUri()`](https://fakerjs.dev/api/image.html#datauri) (returns a SVG string).
13
14
*
14
-
* For a random user avatar image, use [`avatar()`](https://fakerjs.dev/api/image.html#avatar).
15
+
* For a random user avatar image, use [`avatar()`](https://fakerjs.dev/api/image.html#avatar), or [`personPortrait()`](https://fakerjs.dev/api/image.html#personportrait) which has more control over the size and sex of the person.
15
16
*
16
17
* If you need more control over the content of the images, you can pass a `category` parameter e.g. `'cat'` or `'nature'` to [`urlLoremFlickr()`](https://fakerjs.dev/api/image.html#urlloremflickr) or simply use [`faker.helpers.arrayElement()`](https://fakerjs.dev/api/helpers.html#arrayelement) with your own array of image URLs.
17
18
*/
@@ -27,7 +28,11 @@ export class ImageModule extends ModuleBase {
27
28
*/
28
29
avatar(): string{
29
30
// Add new avatar providers here, when adding a new one.
@@ -45,6 +50,45 @@ export class ImageModule extends ModuleBase {
45
50
)}`;
46
51
}
47
52
53
+
/**
54
+
* Generates a random square portrait (avatar) of a person.
55
+
* These are static images of fictional people created by an AI, Stable Diffusion 3.
56
+
* The image URLs are served via the JSDelivr CDN and subject to their [terms of use](https://www.jsdelivr.com/terms).
57
+
*
58
+
* @param options Options for generating an AI avatar.
59
+
* @param options.sex The sex of the person for the avatar. Can be `'female'` or `'male'`. If not provided, defaults to a random selection.
60
+
* @param options.size The size of the image. Can be `512`, `256`, `128`, `64` or `32`. If not provided, defaults to `512`.
* Generates a random avatar from `https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar`.
50
94
*
@@ -59,7 +103,7 @@ export class ImageModule extends ModuleBase {
59
103
avatarLegacy(): string{
60
104
deprecated({
61
105
deprecated: 'faker.image.avatarLegacy()',
62
-
proposed: 'faker.image.avatar()',
106
+
proposed: 'faker.image.avatar() or faker.image.personPortrait()',
exports[`image > 42 > personPortrait > with sex 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/female/512/37.jpg"`;
28
+
29
+
exports[`image > 42 > personPortrait > with sex and size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/male/256/37.jpg"`;
30
+
31
+
exports[`image > 42 > personPortrait > with size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/female/128/95.jpg"`;
exports[`image > 1211 > personPortrait > with sex 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/female/512/92.jpg"`;
112
+
113
+
exports[`image > 1211 > personPortrait > with sex and size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/male/256/92.jpg"`;
114
+
115
+
exports[`image > 1211 > personPortrait > with size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/male/128/89.jpg"`;
exports[`image > 1337 > personPortrait > with sex 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/female/512/26.jpg"`;
196
+
197
+
exports[`image > 1337 > personPortrait > with sex and size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/male/256/26.jpg"`;
198
+
199
+
exports[`image > 1337 > personPortrait > with size 1`] =`"https://cdn.jsdelivr.net/gh/faker-js/assets-person-portrait/female/128/15.jpg"`;
0 commit comments