Commits

Konstantinos Metaxas committed 335984e

use newer sorl-thumbnail that does not have ImageWithThumbnailField

  • Participants
  • Parent commits 8f75119

Comments (0)

Files changed (3)

File profile/models.py

 from django.contrib.contenttypes import generic
 from django.core.urlresolvers import reverse
 from django.dispatch import dispatcher
-from sorl.thumbnail.fields import ImageWithThumbnailsField
+from sorl.thumbnail import ImageField
 import os
 from os import path
 
             blank=True,null=True)
 
 
-    avatar = ImageWithThumbnailsField(
-            thumbnail={
-                'size': (50, 50),
-                'options':['crop','upscale'],
-                },
-            extra_thumbnails={
-                'large': {'size': (80, 80)},
-                },
-            verbose_name = _("Avatar"),
+    avatar = ImageField( _("Avatar"),
             upload_to = 'images/profiles/%Y/%m/',
             help_text=_("Optional"),
             blank=True,null=True,
-
             )
     category = models.CharField(_("Category"),
             max_length = 3,

File profile/templatetags/marktag.py

 from django import template
 from django.conf import settings
 from genmap.profile.models import Profile
+from sorl.thumbnail import get_thumbnail
 
 if settings.GRAVATAR:
     from gravatar.templatetags.gravatar_tags import gravatar_for_user
     else: size = 50
 
     if mark.avatar:
-        if large: src = mark.avatar.extra_thumbnails['large']
-        else: src = mark.avatar.thumbnail
+        if large:
+            size = "80x80"
+        else:
+            size = "50x50"
+        thumb = get_thumbnail(mark.avatar, size , crop='center',
+                quality=95,upscale=True )
+        src = thumb.url
     elif settings.GRAVATAR:
         src = gravatar_for_user(mark.user, size)
     else:

File profile/views.py

 from django.contrib.gis.geos import *
 from django.contrib.gis.measure import D
 
+from sorl.thumbnail import get_thumbnail
+
+
 if settings.GRAVATAR:
     from gravatar.templatetags.gravatar_tags import gravatar_for_user
 
         mark_country = mark.country
         doc._push()
         if mark.avatar:
-            thumbnail =  unicode(mark.avatar.thumbnail)
+            thumb = get_thumbnail(mark.avatar, '50x50', crop='center',
+                    quality=95,upscale=True )
+            thumbnail =  thumb.url
         elif settings.GRAVATAR:
             thumbnail = gravatar_for_user(mark.user, 50)
         else: