image
With this method the default image provider is placeimg
but you can also use unsplash
as image provider. In next topics it will be explained how to do it.
image​
Description​
Method that generate image url with random category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
options.keyword | <String> | What keyword image has to have. This parameter is specific to unsplash provider. Default value is empty |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.image());
- result
'https://placeimg.com/640/480/tech'
Describing that i want an image size of
200x250
- code
console.log(pure.image.image({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/arch'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.image({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/arch'
Describing that i want an image size of
200x250
usingunsplash
as provider and keywordtree
- code
console.log(pure.image.unsplash.image({ width: '200', height: '250', keyword: 'tree' }));
- result
'https://source.unsplash.com/200x250?tree'
avatar​
Description​
Method that generate random avatar. Same as Avatar
Parameters​
Name | Type | Description |
---|---|---|
N/A | N/A | This method doesn't receive any parameters |
Returns​
- <String>
Usage​
- Without passing parameters
- code
console.log(pure.image.avatar());
- result
'https://i.pravatar.cc/200'
animals​
Description​
Method that generate image url specific from placeimg
with animals category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.animals());
- result
'https://placeimg.com/640/480/animals'
Describing that i want an image size of
200x250
- code
console.log(pure.image.animals({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/animals'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.animals({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/animals'
food​
Description​
Method that generate image url specific from unsplash
with food category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.unsplash.food());
- result
'https://source.unsplash.com/640x480?food'
Describing that i want an image size of
200x250
- code
console.log(pure.image.unsplash.food({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?food'
architecture​
Description​
Method that generate image url specific from placeimg
with architecture category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.architecture());
- result
'https://placeimg.com/640/480/arch'
Describing that i want an image size of
200x250
- code
console.log(pure.image.architecture({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/arch'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.architecture({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/arch'
people​
Description​
Method that generate image url for both providers with people category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
options.keyword | <String> | What keyword image has to have. This parameter is specific to unsplash provider. Default value is empty |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.people());
- result
'https://placeimg.com/640/480/people'
Describing that i want an image size of
200x250
- code
console.log(pure.image.people({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/people'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.people({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/people'
Describing that i want an image size of
200x250
usingunsplash
as provider- code
console.log(pure.image.unsplash.people({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?people'
nature​
Description​
Method that generate image url for both providers with nature category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
options.keyword | <String> | What keyword image has to have. This parameter is specific to unsplash provider. Default value is empty |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.nature());
- result
'https://placeimg.com/640/480/nature'
Describing that i want an image size of
200x250
- code
console.log(pure.image.nature({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/nature'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.nature({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/nature'
Describing that i want an image size of
200x250
usingunsplash
as provider- code
console.log(pure.image.unsplash.nature({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?nature'
tech​
Description​
Method that generate image url specific from placeimg
with tech category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.tech());
- result
'https://placeimg.com/640/480/tech'
Describing that i want an image size of
200x250
- code
console.log(pure.image.tech({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/tech'
Describing that i want an image size of
200x250
usingplaceimg
as provider- code
console.log(pure.image.placeimg.tech({ width: '200', height: '250' }));
- result
'https://placeimg.com/200/250/tech'
technology​
Description​
Method that generate image url specific from unsplash
with technology category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.unsplash.technology());
- result
'https://source.unsplash.com/640x480?technology'
Describing that i want an image size of
200x250
- code
console.log(pure.image.unsplash.technology({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?technology'
objects​
Description​
Method that generate image url specific from unsplash
with objects category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.unsplash.objects());
- result
'https://source.unsplash.com/640x480?objects'
Describing that i want an image size of
200x250
- code
console.log(pure.image.unsplash.objects({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?objects'
buildings​
Description​
Method that generate image url specific from unsplash
with buildings category
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated image. Default value is 640 |
options.height | <Number> | Height of the generated image. Default value is 480 |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.unsplash.buildings());
- result
'https://source.unsplash.com/640x480?buildings'
Describing that i want an image size of
200x250
- code
console.log(pure.image.unsplash.buildings({ width: '200', height: '250' }));
- result
'https://source.unsplash.com/200x250?buildings'
dataUri​
Description​
Method that generate random data URI
Parameters​
Name | Type | Description |
---|---|---|
options | <Object> | You can pass parameters as this object properties |
options.width | <Number> | Width of the generated URI. Default value is 640 |
options.height | <Number> | Height of the generated URI. Default value is 480 |
options.color | <Number> | Color name of the generated URI. Default value is random |
Returns​
- <String>
Usage​
Without passing parameters
- code
console.log(pure.image.dataUri());
- result
'data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22640%22%20height%3D%22480%22%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22pink%22%2F%3E%3Ctext%20x%3D%22320%22%20y%3D%22240%22%20font-size%3D%2220%22%20alignment-baseline%3D%22middle%22%20text-anchor%3D%22middle%22%20fill%3D%22white%22%3E640x480%3C%2Ftext%3E%3C%2Fsvg%3E'
Describing that i want an image size of
200x250
- code
console.log(pure.image.dataUri({ width: '200', height: '250', color: 'green' }));
- result
'data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20baseProfile%3D%22full%22%20width%3D%22200%22%20height%3D%22250%22%3E%3Crect%20width%3D%22100%25%22%20height%3D%22100%25%22%20fill%3D%22green%22%2F%3E%3Ctext%20x%3D%22100%22%20y%3D%22125%22%20font-size%3D%2220%22%20alignment-baseline%3D%22middle%22%20text-anchor%3D%22middle%22%20fill%3D%22white%22%3E200x250%3C%2Ftext%3E%3C%2Fsvg%3E'