Skip to content

Commit 508d7d9

Browse files
authored
Update Image.php
1 parent 31c7dc7 commit 508d7d9

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

src/Filters/Image.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,28 @@ public function __construct(string $path, string $dir = 'thumbnails', int $multi
3333
*/
3434
public function format(string $url, int $width, int $height, int $mode = \Nette\Utils\Image::OrSmaller, int $format = IMAGETYPE_WEBP): string
3535
{
36+
$originalUrl = $url;
37+
3638
$isRemoteUrl = $this->isRemoteUrl($url);
3739

3840
// original file does not exist
3941
if ($isRemoteUrl) {
4042
$contents = @file_get_contents($url);
4143
if (!$contents) {
42-
return $url;
44+
return $originalUrl;
4345
}
4446

4547
list($urlWithoutExtension,) = $this->splitUrlOnLastDot($this->removeProtocol($url));
4648

4749
} else {
4850
$url = trim($url, '/');
4951
if (!file_exists($this->path . '/' . $url)) {
50-
return $url;
52+
return $originalUrl;
5153
}
5254
$contents = file_get_contents($this->path . '/' . $url);
5355

5456
if ($this->isAnimatedGif($contents)) {
55-
return $url;
57+
return $originalUrl;
5658
}
5759

5860
list($urlWithoutExtension,) = $this->splitUrlOnLastDot($url);
@@ -62,7 +64,7 @@ public function format(string $url, int $width, int $height, int $mode = \Nette\
6264
$height = $height * $this->multiplier;
6365
$ext = pathinfo(parse_url($url, PHP_URL_PATH), PATHINFO_EXTENSION);
6466
if ($ext === 'svg') {
65-
return $url;
67+
return $originalUrl;
6668
}
6769

6870
$newFile = $this->dir . '/' . $urlWithoutExtension . '_' . $width . '_' . $height . '_' . $mode . '_' . $ext . '.' . self::FormatToExtensions[$format];

0 commit comments

Comments
 (0)