designtopack/public/site/plugins/helpers/index.php

37 lines
1.1 KiB
PHP
Raw Normal View History

2024-10-16 17:32:15 +02:00
<?php
function getFileData($file) {
$data = [
2024-11-18 15:52:15 +01:00
'modified' => $file->modified('YYYY-MM-dd'),
2024-12-17 11:27:02 +01:00
'url' => $file->thumb([
'width' => 1000,
'quality' => 80,
'format' => 'webp'
])->url(),
2024-12-20 07:19:46 +01:00
'parent' => [
"title" => (string) $file->parent()->title(),
"uri" => $file->parent()->uri()
],
2024-10-16 17:32:15 +02:00
'uuid' => (string) $file->uuid(),
'name' => $file->filename(),
2024-11-18 15:52:15 +01:00
'label' => (string) $file->label(),
2024-10-23 11:32:51 +02:00
'type' => (string) $file->type(),
2024-12-19 19:27:38 +01:00
'cover' => $file->cover()->isNotEmpty() ? $file->cover()->toFile()->thumb([
'width' => 1000,
'quality' => 80,
'format' => 'webp'
])->url() : null
2024-10-16 17:32:15 +02:00
];
if ($file->description()->exists()) {
2024-10-16 17:57:50 +02:00
$data['description'] = $file->description()->value();
2024-10-16 17:32:15 +02:00
$data['tags'] = $file->tags()->split();
};
2024-12-19 17:11:46 +01:00
if($file->comments()->exists()) {
2024-11-28 14:45:45 +01:00
$data['comments'] = $file->comments()->exists() && $file->comments() ? Data::decode($file->comments()->value(), 'yaml') : [];
2024-11-28 16:56:55 +01:00
$data['cover'] = $file->cover()->exists() && $file->cover()->isNotEmpty() ? $file->cover()->toFile()->resize(576)->url() : false;
2024-11-28 14:45:45 +01:00
}
2024-10-23 11:32:51 +02:00
2024-10-16 17:32:15 +02:00
return $data;
}