тумбы

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def thumb_(self):
tiny = path.join(path.dirname(self.get_img_filename()),
'thumb_' + path.basename(self.get_img_filename()))
if not path.exists(tiny):
im = Image.open(self.get_img_filename())
im.thumbnail(TINY_SIZE, Image.ANTIALIAS)
im.save(tiny, 'JPEG')
tiny_url = path.join(settings.MEDIA_URL, path.dirname(self.img),
'thumb_' + path.basename(self.img))
ancore = '<a href="%s" target="_blank"><img src="%s" alt="thumbnail of %s"/></a>' % \
(self.get_img_url(), tiny_url, self.alt)
return ancore
thumb_.allow_tags = True
thumb_.short_description = 'thumb'