示例#1
0
class PicasaAdminImageWidget(AdminFileWidget):
    # A FileField Widget that displays an image instead of a file path
    # if the current file is an image.
    storage = PicasaStorage()
    SIZE=64
    def render(self, name, photo, attrs=None):
        output = []
        if photo:
            src = photo.src(self.SIZE)
            try:            # is image
                output.append(r'<a target="_blank" href="%s"><img src="%s" align="left" valign="middle" /></a>' % (photo.url, src))
                #output.append('%s <a target="_blank" href="%s">%s</a> <br/>%s' % (_('Currently:'), file_path, file_name, _('Change:')))
            except:
                output.append('Not an image ')
        else:
            output.append('Add:')
        output.append(super(AdminFileWidget, self).render(name, photo, attrs))
        return mark_safe(u''.join(output))
示例#2
0
 def __init__(self, *args, **kwargs):
     super(PicasaFieldFile, self).__init__(*args, **kwargs)
     self.storage = PicasaStorage()