Add: filter to check if file is flash

This commit is contained in:
Aroy-Art 2024-06-04 10:33:55 +02:00
parent a8d5d4d289
commit 4af5fdf9e0
Signed by: Aroy
GPG key ID: DB9689E9391DD156

View file

@ -2,8 +2,6 @@ from django import template
register = template.Library() register = template.Library()
#from mimetypes import guess_type
@register.filter @register.filter
def is_image (mime_type): 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 A function that takes the mime type as input and returns true if it is an video
''' '''
return mime_type.startswith('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