From 8577f733d94a077127561f73cfdd5a85d6c71a2b Mon Sep 17 00:00:00 2001 From: neutralrockets Date: Thu, 31 Dec 2015 09:12:04 +1100 Subject: [PATCH] Update Image.php Add ability to generate gray images by providing "true" as the final parameter to imageUrl(). --- src/Faker/Provider/Image.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Faker/Provider/Image.php b/src/Faker/Provider/Image.php index 0def1371bc..0e31d50fae 100644 --- a/src/Faker/Provider/Image.php +++ b/src/Faker/Provider/Image.php @@ -19,9 +19,15 @@ class Image extends Base * * @example 'http://lorempixel.com/640/480/?12345' */ - public static function imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null) + public static function imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false) { - $url = "http://lorempixel.com/{$width}/{$height}/"; + $baseUrl = "http://lorempixel.com/"; + $url = "{$width}/{$height}/"; + + if ($gray) { + $url = "gray/" . $url; + } + if ($category) { if (!in_array($category, static::$categories)) { throw new \InvalidArgumentException(sprintf('Unknown image category "%s"', $category)); @@ -36,7 +42,7 @@ public static function imageUrl($width = 640, $height = 480, $category = null, $ $url .= '?' . static::randomNumber(5, true); } - return $url; + return $baseUrl . $url; } /**