28 lines
No EOL
840 B
PHP
28 lines
No EOL
840 B
PHP
<?php
|
|
|
|
function getFileData($file) {
|
|
$data = [
|
|
'modified' => $file->modified('YYYY-MM-dd'),
|
|
'url' => $file->thumb([
|
|
'width' => 1000,
|
|
'quality' => 80,
|
|
'format' => 'webp'
|
|
])->url(),
|
|
'uuid' => (string) $file->uuid(),
|
|
'name' => $file->filename(),
|
|
'label' => (string) $file->label(),
|
|
'type' => (string) $file->type(),
|
|
];
|
|
|
|
if ($file->description()->exists()) {
|
|
$data['description'] = $file->description()->value();
|
|
$data['tags'] = $file->tags()->split();
|
|
};
|
|
|
|
if($file->extension() == "pdf") {
|
|
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
|
|
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
|
|
}
|
|
|
|
return $data;
|
|
} |