Add: Basic template tags for media filtering
This commit is contained in:
parent
640ed5a07d
commit
9d1453120e
2 changed files with 20 additions and 0 deletions
0
archivist/apps/sites/templatetags/__init__.py
Normal file
0
archivist/apps/sites/templatetags/__init__.py
Normal file
20
archivist/apps/sites/templatetags/media_filters.py
Normal file
20
archivist/apps/sites/templatetags/media_filters.py
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
from django import template
|
||||||
|
|
||||||
|
register = template.Library()
|
||||||
|
|
||||||
|
#from mimetypes import guess_type
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def is_image (mime_type):
|
||||||
|
'''
|
||||||
|
A function that takes the mime type as input and returns true if it is an image
|
||||||
|
'''
|
||||||
|
return mime_type.startswith('image/')
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
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/')
|
Loading…
Reference in a new issue