Image

Module to generate placeholder images.

Default provider is unsplash image provider.

Abstract

Generates a random abstract image url.

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

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

Animals

Generates a random animal image url.

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

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

Avatar

Generates a random avatar image url.

Returns: string

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.

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

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

Cats

Generates a random cat image url.

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

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

City

Generates a random city image url.

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

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

Data Uri

Generates a random data uri containing an svg image.

Parameters

NameTypeDefaultDescription
width?number640

The width of the image.

height?number480

The height of the image.

colorstring'grey'

The color to use.

Returns: string

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.

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

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

Food

Generates a random food image url.

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

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

Image

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

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

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

Image Url

Generates a random image url.

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.

https?boolean

When true, return a https url. Otherwise, return a http url.

Returns: string

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

Nature

Generates a random nature image url.

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

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

Nightlife

Generates a random nightlife image url.

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

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

People

Generates a random people image url.

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

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

Sports

Generates a random sports image url.

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

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

Technics

Generates a random technics image url.

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

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

Transport

Generates a random transport image url.

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

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