Skip to content

Commit 002ba4d

Browse files
authored
Merge pull request #4879 from Laravel-Backpack/image-column-support-private-bucket
Image column support private bucket
2 parents 0ce1e6c + 8cd84c8 commit 002ba4d

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/resources/views/crud/columns/image.blade.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
$column['width'] = $column['width'] ?? "auto";
88
$column['radius'] = $column['radius'] ?? "3px";
99
$column['prefix'] = $column['prefix'] ?? '';
10+
$column['temporary'] = $column['temporary'] ?? false;
11+
$column['expiration'] = $column['expiration'] ?? 1;
1012
1113
if($column['value'] instanceof \Closure) {
1214
$column['value'] = $column['value']($entry);
@@ -19,7 +21,13 @@
1921
if (preg_match('/^data\:image\//', $column['value'])) { // base64_image
2022
$href = $src = $column['value'];
2123
} elseif (isset($column['disk'])) { // image from a different disk (like s3 bucket)
22-
$href = $src = Storage::disk($column['disk'])->url($column['prefix'].$column['value']);
24+
25+
if (!empty($column['temporary'])) {
26+
$href = $src = Storage::disk($column['disk'])->temporaryUrl($column['prefix'].$column['value'], now()->addMinutes((int) $column['expiration']));
27+
} else {
28+
$href = $src = Storage::disk($column['disk'])->url($column['prefix'].$column['value']);
29+
}
30+
2331
} else { // plain-old image, from a local disk
2432
$href = $src = asset($column['prefix'] . $column['value']);
2533
}

0 commit comments

Comments
 (0)