From a6868c10fcbea80f5f389e5dc4fc3fbe740c6b29 Mon Sep 17 00:00:00 2001 From: Jiangti Wan-Leong Date: Wed, 15 Sep 2021 14:49:11 +1000 Subject: [PATCH 1/5] Composer name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index b7a5535..65ac400 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "shadercloud/laravel-thumbnail", + "name": "jiangti/laravel-thumbnail", "description": "Laravel Thumbnail generator", "keywords": ["laravel", "image", "thumbnail"], "license": "MIT", From 9b32b86426f5c6a7eef5ee074a7a604bf60bcc74 Mon Sep 17 00:00:00 2001 From: Jiangti Wan-Leong Date: Wed, 15 Sep 2021 14:57:04 +1000 Subject: [PATCH 2/5] Change to CURL --- src/Source.php | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/Source.php b/src/Source.php index 35258ea..66a7aeb 100644 --- a/src/Source.php +++ b/src/Source.php @@ -109,7 +109,23 @@ public function getImage(): string if ($this->disk) { return Storage::disk($this->disk)->get($this->path); } else { - $content = file_get_contents($this->path); + $url = $this->path; + + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_TIMEOUT, 20); + curl_setopt($ch, CURLOPT_HEADER , false); + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST , false); + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER , false); + curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true); + curl_setopt($ch, CURLOPT_AUTOREFERER , true); + curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'); + curl_setopt($ch, CURLOPT_FILE, $fp); + $content = curl_exec($ch); + curl_close($ch); + + + if ($content === false) { throw new Exception('Could not get file content for path "' . $this->path . '"'); } From 0554f5f1ab72c09bad2e46118dfc912253724b01 Mon Sep 17 00:00:00 2001 From: Jiangti Wan-Leong Date: Wed, 15 Sep 2021 14:59:02 +1000 Subject: [PATCH 3/5] Oops --- src/Source.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Source.php b/src/Source.php index 66a7aeb..8a56422 100644 --- a/src/Source.php +++ b/src/Source.php @@ -110,7 +110,7 @@ public function getImage(): string return Storage::disk($this->disk)->get($this->path); } else { $url = $this->path; - + $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 20); From d1acb4fbd21b0517f3ea8cd7a950f3aab2935080 Mon Sep 17 00:00:00 2001 From: Jiangti Wan-Leong Date: Wed, 15 Sep 2021 14:59:36 +1000 Subject: [PATCH 4/5] Do not write to file --- src/Source.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Source.php b/src/Source.php index 8a56422..de93bea 100644 --- a/src/Source.php +++ b/src/Source.php @@ -120,7 +120,6 @@ public function getImage(): string curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true); curl_setopt($ch, CURLOPT_AUTOREFERER , true); curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12'); - curl_setopt($ch, CURLOPT_FILE, $fp); $content = curl_exec($ch); curl_close($ch); From 549ae55275cb8f942b732bbb7dc5599660e6a8da Mon Sep 17 00:00:00 2001 From: Jiangti Wan-Leong Date: Wed, 15 Sep 2021 15:08:56 +1000 Subject: [PATCH 5/5] Using own name --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 65ac400..d288040 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "jiangti/laravel-thumbnail", + "name": "rolandstarke/laravel-thumbnail", "description": "Laravel Thumbnail generator", "keywords": ["laravel", "image", "thumbnail"], "license": "MIT",