Skip to content

Commit a5099b8

Browse files
committed
Add inline url
1 parent dba1207 commit a5099b8

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

src/Attachment.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,23 @@ public function getUrlAttribute()
282282
}
283283
}
284284

285+
public function getUrlInlineAttribute()
286+
{
287+
if ($this->isLocalStorage()) {
288+
$extension = $this->extension;
289+
290+
return route('attachments.download', [
291+
'id' => $this->uuid,
292+
'name' => $extension ?
293+
Str::slug(substr($this->filename, 0, -1 * strlen($this->extension) - 1)) . '.' . $this->extension :
294+
Str::slug($this->filename),
295+
'disposition' => 'inline',
296+
]);
297+
} else {
298+
return Storage::disk($this->disk)->url($this->filepath);
299+
}
300+
}
301+
285302

286303
public function toArray()
287304
{
@@ -572,4 +589,4 @@ public function getConnectionName()
572589
{
573590
return config('attachments.database.connection') ?? $this->connection;
574591
}
575-
}
592+
}

0 commit comments

Comments
 (0)