From 1cb75e43a9e50fcc5e0a359acd03251eb75aa6b5 Mon Sep 17 00:00:00 2001 From: Murph Murphy Date: Thu, 10 May 2012 12:21:05 -0600 Subject: [PATCH] Fixed thumbnail template tag to work with images with spaces in them or other url escapes (such as user uploaded photos) --- basic/tools/templatetags/thumbnail.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/basic/tools/templatetags/thumbnail.py b/basic/tools/templatetags/thumbnail.py index e1920c9..a5407a1 100644 --- a/basic/tools/templatetags/thumbnail.py +++ b/basic/tools/templatetags/thumbnail.py @@ -1,5 +1,7 @@ from django import template from django.conf import settings +import urllib + register = template.Library() @@ -23,7 +25,7 @@ def thumbnail(url, size='200x200'): if url.startswith(settings.MEDIA_URL): url = url[len(settings.MEDIA_URL):] - original_path = settings.MEDIA_ROOT + url + original_path = urllib.unquote(settings.MEDIA_ROOT + url) # Define the thumbnail's filename, file path, and URL. try: