From 4af5fdf9e0c2ce8a812fe747ae7fa694c70dc8de Mon Sep 17 00:00:00 2001 From: Aroy-Art Date: Tue, 4 Jun 2024 10:33:55 +0200 Subject: [PATCH] Add: filter to check if file is flash --- .../apps/sites/templatetags/media_filters.py | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/archivist/apps/sites/templatetags/media_filters.py b/archivist/apps/sites/templatetags/media_filters.py index 28e5f81..2dc6963 100644 --- a/archivist/apps/sites/templatetags/media_filters.py +++ b/archivist/apps/sites/templatetags/media_filters.py @@ -2,8 +2,6 @@ from django import template register = template.Library() -#from mimetypes import guess_type - @register.filter def is_image (mime_type): ''' @@ -18,3 +16,22 @@ def is_video (mime_type): A function that takes the mime type as input and returns true if it is an video ''' return mime_type.startswith('video/') + + +@register.filter +def is_flash (mime_type): + ''' + A function that takes the mime type as input and returns true if it is an flash + ''' + + valid_flash_mime_types = [ + 'application/vnd.adobe.flash.movie', + 'application/x-shockwave-flash', + 'application/futuresplash', + 'application/x-swf', + ] + + for valid_type in valid_flash_mime_types: + if valid_type in mime_type: + return True + return False