From d18ec187847893f94418b29bc6a087d6b2dd9a2d Mon Sep 17 00:00:00 2001 From: winter Date: Fri, 7 Feb 2025 18:26:05 +0000 Subject: localise note timestamps and stuff --- Digitigrade/Model/NoteAttachment.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Digitigrade') diff --git a/Digitigrade/Model/NoteAttachment.php b/Digitigrade/Model/NoteAttachment.php index 1ca0064..8c6fb1f 100644 --- a/Digitigrade/Model/NoteAttachment.php +++ b/Digitigrade/Model/NoteAttachment.php @@ -29,4 +29,35 @@ class NoteAttachment extends Model { } return null; } + + /** + * @return bool if this attachment is a supported image file + */ + public function isImage(): bool { + return in_array($this->type, [ + 'image/apng', + 'image/avif', + 'image/gif', + 'image/jpeg', + 'image/png', + 'image/svg+xml', + 'image/webp', + ]); + } + + /** + * @return bool if this attachment 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->type, 'audio/'); + } + + /** + * @return bool if this attachment 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->type, 'video/'); + } } \ No newline at end of file -- cgit v1.3