diff options
Diffstat (limited to 'Digitigrade/Model')
| -rw-r--r-- | Digitigrade/Model/StorageObject.php | 31 |
1 files changed, 31 insertions, 0 deletions
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 |
