Add: filter to check if file is flash
This commit is contained in:
parent
a8d5d4d289
commit
4af5fdf9e0
1 changed files with 19 additions and 2 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue