Skip to content

Commit

Permalink
fix(uploader): properlly display media with full URL
Browse files Browse the repository at this point in the history
  • Loading branch information
uyab committed Jun 2, 2022
1 parent e45e94d commit 47217f5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/Elements/Uploader.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,14 @@ protected function setValue($mediaCollection)
],
];
} else {
$file = public_path(trim($media, '/'));
if (file_exists($file)) {
$mediaUrl = url(trim($media, '/'));
$mediaHeader = @get_headers($mediaUrl, true);
if ($mediaHeader['Content-Length'] > 0) {
$data[] = [
'file' => URL::to($media),
'file' => $mediaUrl,
'name' => basename($media),
'size' => filesize($file),
'type' => mime_content_type($file),
'size' => $mediaHeader['Content-Length'],
'type' => $mediaHeader['Content-Type'] ?? '',
];
}
}
Expand Down

0 comments on commit 47217f5

Please sign in to comment.