From cc5ab7a365e2e045cc1af43727e56f56d088a0df Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 7 Feb 2025 19:45:36 +0000 Subject: more stuff :3 - post form detects images better - post form is preserved across navigations - post form has most options hidden - details/summaries use nicer icons --- Digitigrade/Model/StorageObject.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Digitigrade') diff --git a/Digitigrade/Model/StorageObject.php b/Digitigrade/Model/StorageObject.php index 28c77aa..9d4bc1a 100644 --- a/Digitigrade/Model/StorageObject.php +++ b/Digitigrade/Model/StorageObject.php @@ -108,4 +108,35 @@ class StorageObject extends Model { } return path_to_uri("/storage/$this->oid"); } + + /** + * @return bool if this object is a supported image file + */ + public function isImage(): bool { + return in_array($this->mimetype, [ + 'image/apng', + 'image/avif', + 'image/gif', + 'image/jpeg', + 'image/png', + 'image/svg+xml', + 'image/webp', + ]); + } + + /** + * @return bool if this object is a supported audio file + */ + public function isAudio(): bool { + // TODO: be a bit more careful about what counts as supported + return str_starts_with($this->mimetype, 'audio/'); + } + + /** + * @return bool if this object is a supported video file + */ + public function isVideo(): bool { + // TODO: be a bit more careful about what counts as supported + return str_starts_with($this->mimetype, 'video/'); + } } \ No newline at end of file -- cgit v1.3