def render(self, context):
try:
a = template.resolve_variable(self.photo, context)
except:
a = self.photo
if isinstance(a, Photo):
p = a
else:
try:
p = Photo.objects.get(slug=a)
except Photo.DoesNotExist:
# Ooops. Fail silently
return None
if not p.is_public:
return None
func = getattr(p, 'get_%s_url' % (self.photosize), None)
if func is None:
return 'A "%s" photo size has not been defined.' % (self.photosize)
else:
return u'<img class="%s" src="%s" alt="%s" />' % (self.css_class, func(), p.title)
评论列表
文章目录