Skip to content

Commit c8c0f49

Browse files
authored
Dont download image if not needed (#10)
1 parent 04d8f76 commit c8c0f49

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Service/LocalImageUploader.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,17 @@ public function __construct(string $uploadsFolder, string $webPrefix)
2929

3030
public function uploadImage(string $url): string
3131
{
32-
//Download the file
33-
$file = @\file_get_contents($url);
34-
if (false === $file) {
35-
return '';
36-
}
37-
3832
$filename = \basename($url);
39-
4033
$path = \sprintf('%s/%s', $this->uploadsFolder, $filename);
4134

4235
// Check if file already exists
4336
if (!\file_exists($path)) {
37+
//Download the file
38+
$file = @\file_get_contents($url);
39+
if (false === $file) {
40+
return '';
41+
}
42+
4443
// Save the file
4544
@\mkdir(\dirname($path));
4645
\file_put_contents($path, $file);

0 commit comments

Comments
 (0)