Faker\Provider\Image::imageUrl PHP Method

imageUrl() public static method

Set randomize to false to remove the random GET parameter at the end of the url.
public static imageUrl ( $width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false )
    public static function imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false)
    {
        $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));
            }
            $url .= "{$category}/";
            if ($word) {
                $url .= "{$word}/";
            }
        }
        if ($randomize) {
            $url .= '?' . static::randomNumber(5, true);
        }
        return $baseUrl . $url;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testUrlWithDimensionsAndBadCategory()
 {
     Image::imageUrl(800, 400, 'bullhonky');
 }
All Usage Examples Of Faker\Provider\Image::imageUrl