Skip to content

Commit 4562b12

Browse files
authored
Merge pull request #234 from Muetze42/development
fix(controller): replace `file_get_contents` with HTTP client for image requests
2 parents 8997481 + d41b2ea commit 4562b12

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

app/Http/Controllers/OgImageController.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use GDText\Box;
99
use GDText\Color;
1010
use Illuminate\Http\Request;
11+
use Illuminate\Support\Facades\Http;
1112
use Symfony\Component\HttpFoundation\StreamedResponse;
1213

1314
class OgImageController extends Controller
@@ -169,12 +170,14 @@ protected function wasRecipeBackgroundLoaded(GdImage $canvas, Recipe $recipe): b
169170
return false;
170171
}
171172

172-
$imageContent = file_get_contents($imageUrl);
173+
$response = Http::timeout(10)->get($imageUrl);
173174

174-
if ($imageContent === false) {
175+
if ($response->failed()) {
175176
return false;
176177
}
177178

179+
$imageContent = $response->body();
180+
178181
$sourceImage = imagecreatefromstring($imageContent);
179182

180183
if ($sourceImage === false) {

0 commit comments

Comments
 (0)