Skip to content

Instantly share code, notes, and snippets.

@sinkcup
Created January 10, 2018 07:40
Show Gist options
  • Save sinkcup/9cb5ef3495ad602417c276b0fd78b760 to your computer and use it in GitHub Desktop.
Save sinkcup/9cb5ef3495ad602417c276b0fd78b760 to your computer and use it in GitHub Desktop.
fzaninotto/Faker imageUrl is using https://lorempixel.com, today it down again. I write a patch to switch to https://fakeimg.pl
{
"name": "laravel/laravel",
"scripts": {
"post-install-cmd": [
"patch -N -p0 < faker_image_url.patch || echo 'patch failed'"
]
}
}
--- vendor/fzaninotto/faker/src/Faker/Provider/Image.php 2017-08-16 00:48:10.000000000 +0800
+++ Image.php 2018-01-10 15:25:31.384804140 +0800
@@ -30,22 +30,8 @@
*/
public static function imageUrl($width = 640, $height = 480, $category = null, $randomize = true, $word = null, $gray = false)
{
- $baseUrl = "https://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}/";
- }
- }
+ $baseUrl = "https://fakeimg.pl/";
+ $url = "{$width}x{$height}/";
if ($randomize) {
$url .= '?' . static::randomNumber(5, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment