Skip to content

Commit 4fc6a14

Browse files
authored
fixes #1686 by providing absolute path if not set (#1998)
1 parent ed6e157 commit 4fc6a14

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

app/Console/Commands/PhotosAddedNotification.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
use Illuminate\Console\Command;
1010
use Illuminate\Notifications\DatabaseNotification;
1111
use Illuminate\Support\Facades\Mail;
12+
use Illuminate\Support\Facades\URL;
13+
use Illuminate\Support\Str;
1214

1315
class PhotosAddedNotification extends Command
1416
{
@@ -59,6 +61,12 @@ public function handle(): int
5961

6062
$thumbUrl = $photo->size_variants->getThumb()?->url;
6163

64+
// Mail clients do not like relative paths.
65+
// if url does not start with 'http', it is not absolute...
66+
if (!Str::startsWith('http', $thumbUrl)) {
67+
$thumbUrl = URL::asset($thumbUrl);
68+
}
69+
6270
// If the url config doesn't contain a trailing slash then add it
6371
if (str_ends_with(config('app.url'), '/')) {
6472
$trailing_slash = '';

app/Models/SizeVariant.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
use Illuminate\Database\Eloquent\Model;
2222
use Illuminate\Database\Eloquent\Relations\BelongsTo;
2323
use Illuminate\Support\Facades\Auth;
24+
use Illuminate\Support\Facades\URL;
2425
use League\Flysystem\Local\LocalFilesystemAdapter;
2526

2627
// TODO: Uncomment the following line, if Lychee really starts to support AWS s3.

0 commit comments

Comments
 (0)