aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model/NoteAttachment.php
diff options
context:
space:
mode:
Diffstat (limited to 'Digitigrade/Model/NoteAttachment.php')
-rw-r--r--Digitigrade/Model/NoteAttachment.php31
1 files changed, 31 insertions, 0 deletions
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