Add: Basic template tags for media filtering

This commit is contained in:
Aroy-Art 2024-05-08 21:53:36 +02:00
parent 640ed5a07d
commit 9d1453120e
Signed by: Aroy
GPG key ID: 583642324A1D2070
2 changed files with 20 additions and 0 deletions

View 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/')