diff options
| author | Jakub Mandula <[email protected]> | 2017-02-26 13:51:40 +0000 |
|---|---|---|
| committer | Jakub Mandula <[email protected]> | 2017-02-26 13:51:40 +0000 |
| commit | 232a2a58d70935c57d311b5ba237347f703c2131 (patch) | |
| tree | 69f695e62e17386988c47f8522bf5e14db193839 /lib/image.js | |
| parent | d6c20353360ef1eefb56128eeb50ece4f5845372 (diff) | |
| parent | f379057be0112d6732b056d93d1380be18e1087a (diff) | |
| download | faker-232a2a58d70935c57d311b5ba237347f703c2131.tar.xz faker-232a2a58d70935c57d311b5ba237347f703c2131.zip | |
Merge branch 'Mark/origin' into creditCard
Diffstat (limited to 'lib/image.js')
| -rw-r--r-- | lib/image.js | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/lib/image.js b/lib/image.js index 20576d92..dc512a68 100644 --- a/lib/image.js +++ b/lib/image.js @@ -35,11 +35,14 @@ var Image = function (faker) { * @param {boolean} randomize * @method faker.image.imageUrl */ - self.imageUrl = function (width, height, category, randomize) { + self.imageUrl = function (width, height, category, randomize, https) { var width = width || 640; var height = height || 480; - - var url ='http://lorempixel.com/' + width + '/' + height; + var protocol = 'http://'; + if (typeof https !== 'undefined' && https === true) { + protocol = 'https://'; + } + var url = protocol + 'lorempixel.com/' + width + '/' + height; if (typeof category !== 'undefined') { url += '/' + category; } @@ -192,7 +195,19 @@ var Image = function (faker) { */ self.transport = function (width, height, randomize) { return faker.image.imageUrl(width, height, 'transport', randomize); - } + }; + /** + * dataUri + * + * @param {number} width + * @param {number} height + * @method faker.image.dataurl + */ + self.dataUri = function (width, height) { + var rawPrefix = 'data:image/svg+xml;charset=UTF-8,'; + var svgString = '<svg xmlns="http://www.w3.org/2000/svg" version="1.1" baseProfile="full" width="' + width + '" height="' + height + '"> <rect width="100%" height="100%" fill="grey"/> <text x="0" y="20" font-size="20" text-anchor="start" fill="white">' + width + 'x' + height + '</text> </svg>'; + return rawPrefix + encodeURIComponent(svgString); + }; } module["exports"] = Image;
\ No newline at end of file |
