diff --git a/archivist/apps/sites/templatetags/media_filters.py b/archivist/apps/sites/templatetags/media_filters.py index 2dc6963..d858604 100644 --- a/archivist/apps/sites/templatetags/media_filters.py +++ b/archivist/apps/sites/templatetags/media_filters.py @@ -35,3 +35,21 @@ def is_flash (mime_type): if valid_type in mime_type: return True return False + + +@register.filter +def is_pdf(mime_type): + """ + A function that takes the mime type as input and returns true if it is an pdf + """ + valid_pdf_mime_types = [ + "application/pdf", + "application/vnd.cups-pdf", + "application/x-pdf", + ] + + for valid_type in valid_pdf_mime_types: + if valid_type in mime_type: + return True + + return False