Skip to content
On this page

Image

Module to generate placeholder images.

Default provider is unsplash image provider.

abstract

Generates a random abstract image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.abstract(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.abstract() // => "https://loremflickr.com/640/480/abstract"
faker.image.abstract() // 'https://loremflickr.com/640/480/abstract'
faker.image.abstract(1234, 2345) // 'https://loremflickr.com/1234/2345/abstract'
faker.image.abstract(1234, 2345, true) // 'https://loremflickr.com/1234/2345/abstract?lock=56789'

animals

Generates a random animal image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.animals(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.animals() // => "https://loremflickr.com/640/480/animals"
faker.image.animals() // 'https://loremflickr.com/640/480/animals'
faker.image.animals(1234, 2345) // 'https://loremflickr.com/1234/2345/animals'
faker.image.animals(1234, 2345, true) // 'https://loremflickr.com/1234/2345/animals?lock=56789'

avatar

Generates a random avatar image url.

Available since v2.0.1

Returns: string

ts
faker.image.avatar(): string
faker.image.avatar() // => "https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHir...
faker.image.avatar()
// 'https://cloudflare-ipfs.com/ipfs/Qmd3W5DuhgHirLHGVixi6V76LhCkZUz6pnFt5AJBiyvHye/avatar/170.jpg'

business

Generates a random business image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.business(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.business() // => "https://loremflickr.com/640/480/business"
faker.image.business() // 'https://loremflickr.com/640/480/business'
faker.image.business(1234, 2345) // 'https://loremflickr.com/1234/2345/business'
faker.image.business(1234, 2345, true) // 'https://loremflickr.com/1234/2345/business?lock=56789'

cats

Generates a random cat image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.cats(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.cats() // => "https://loremflickr.com/640/480/cats"
faker.image.cats() // 'https://loremflickr.com/640/480/cats'
faker.image.cats(1234, 2345) // 'https://loremflickr.com/1234/2345/cats'
faker.image.cats(1234, 2345, true) // 'https://loremflickr.com/1234/2345/cats?lock=56789'

city

Generates a random city image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.city(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.city() // => "https://loremflickr.com/640/480/city"
faker.image.city() // 'https://loremflickr.com/640/480/city'
faker.image.city(1234, 2345) // 'https://loremflickr.com/1234/2345/city'
faker.image.city(1234, 2345, true) // 'https://loremflickr.com/1234/2345/city?lock=56789'

dataUri

Generates a random data uri containing an svg image.

Available since v4.0.0

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

colorstring'grey'

The color to use.

Returns: string

ts
faker.image.dataUri(width?: number = 640, height?: number = 480, color: string = 'grey'): string
faker.image.dataUri() // => "data:image/svg+xml;charset=UTF-8,%3Csvg%20xmln...
faker.image.dataUri() // 'data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http...'

fashion

Generates a random fashion image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.fashion(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.fashion() // => "https://loremflickr.com/640/480/fashion"
faker.image.fashion() // 'https://loremflickr.com/640/480/fashion'
faker.image.fashion(1234, 2345) // 'https://loremflickr.com/1234/2345/fashion'
faker.image.fashion(1234, 2345, true) // 'https://loremflickr.com/1234/2345/fashion?lock=56789'

food

Generates a random food image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.food(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.food() // => "https://loremflickr.com/640/480/food"
faker.image.food() // 'https://loremflickr.com/640/480/food'
faker.image.food(1234, 2345) // 'https://loremflickr.com/1234/2345/food'
faker.image.food(1234, 2345, true) // 'https://loremflickr.com/1234/2345/food?lock=56789'

image

Generates a random image url from one of the supported categories.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.image(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.image() // => "https://loremflickr.com/640/480/fashion"
faker.image.image() // 'https://loremflickr.com/640/480/city'
faker.image.image(1234, 2345) // 'https://loremflickr.com/1234/2345/sports'
faker.image.image(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789'

imageUrl

Generates a random image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

category?string

The category of the image. By default, a random one will be selected.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.imageUrl(width?: number = 640, height?: number = 480, category?: string, randomize?: boolean = false): string
faker.image.imageUrl() // => "https://loremflickr.com/640/480"
faker.image.imageUrl() // 'https://loremflickr.com/640/480'
faker.image.imageUrl(1234, 2345) // 'https://loremflickr.com/1234/2345'
faker.image.imageUrl(1234, 2345, 'cat') // 'https://loremflickr.com/1234/2345/cat'
faker.image.imageUrl(1234, 2345, 'cat', true) // 'https://loremflickr.com/1234/2345/cat?lock=6849'

nature

Generates a random nature image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.nature(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.nature() // => "https://loremflickr.com/640/480/nature"
faker.image.nature() // 'https://loremflickr.com/640/480/nature'
faker.image.nature(1234, 2345) // 'https://loremflickr.com/1234/2345/nature'
faker.image.nature(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nature?lock=56789'

nightlife

Generates a random nightlife image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.nightlife(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.nightlife() // => "https://loremflickr.com/640/480/nightlife"
faker.image.nightlife() // 'https://loremflickr.com/640/480/nightlife'
faker.image.nightlife(1234, 2345) // 'https://loremflickr.com/1234/2345/nightlife'
faker.image.nightlife(1234, 2345, true) // 'https://loremflickr.com/1234/2345/nightlife?lock=56789'

people

Generates a random people image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.people(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.people() // => "https://loremflickr.com/640/480/people"
faker.image.people() // 'https://loremflickr.com/640/480/people'
faker.image.people(1234, 2345) // 'https://loremflickr.com/1234/2345/people'
faker.image.people(1234, 2345, true) // 'https://loremflickr.com/1234/2345/people?lock=56789'

sports

Generates a random sports image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.sports(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.sports() // => "https://loremflickr.com/640/480/sports"
faker.image.sports() // 'https://loremflickr.com/640/480/sports'
faker.image.sports(1234, 2345) // 'https://loremflickr.com/1234/2345/sports'
faker.image.sports(1234, 2345, true) // 'https://loremflickr.com/1234/2345/sports?lock=56789'

technics

Generates a random technics image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.technics(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.technics() // => "https://loremflickr.com/640/480/technics"
faker.image.technics() // 'https://loremflickr.com/640/480/technics'
faker.image.technics(1234, 2345) // 'https://loremflickr.com/1234/2345/technics'
faker.image.technics(1234, 2345, true) // 'https://loremflickr.com/1234/2345/technics?lock=56789'

transport

Generates a random transport image url.

Available since v2.0.1

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

randomize?booleanfalse

Whether to randomize the image or not.

Returns: string

ts
faker.image.transport(width?: number = 640, height?: number = 480, randomize?: boolean = false): string
faker.image.transport() // => "https://loremflickr.com/640/480/transport"
faker.image.transport() // 'https://loremflickr.com/640/480/transport'
faker.image.transport(1234, 2345) // 'https://loremflickr.com/1234/2345/transport'
faker.image.transport(1234, 2345, true) // 'https://loremflickr.com/1234/2345/transport?lock=56789'

Released under the MIT License.