We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 63c2b24 commit 4358544Copy full SHA for 4358544
src/Image.php
@@ -365,6 +365,19 @@ public function createFromImage(string $image): GdImage|false
365
$image = PathUtility::getAbsolutePath($image);
366
}
367
368
+ if (!file_exists($image)) {
369
+ $imageAlt1 = $_SERVER['DOCUMENT_ROOT'] . $image;
370
+ $imageAlt2 = $_SERVER['DOCUMENT_ROOT'] . '/' . $image;
371
+
372
+ if (file_exists($imageAlt1)) {
373
+ $image = $imageAlt1;
374
+ } elseif (file_exists($imageAlt2)) {
375
+ $image = $imageAlt2;
376
+ } else {
377
+ throw new \Exception("File not found: " . $image);
378
+ }
379
380
381
$resource = imagecreatefromstring((string)file_get_contents($image));
382
if (!$resource) {
383
throw new \Exception('Can\'t create GD resource.');
0 commit comments