def record_to_html(self, cr, uid, field_name, record, options=None, context=None):
if options is None: options = {}
aclasses = ['img', 'img-responsive'] + options.get('class', '').split()
classes = ' '.join(itertools.imap(escape, aclasses))
max_size = None
max_width, max_height = options.get('max_width', 0), options.get('max_height', 0)
if max_width or max_height:
max_size = '%sx%s' % (max_width, max_height)
src = self.pool['website'].image_url(cr, uid, record, field_name, max_size)
alt = None
if options.get('alt-field') and getattr(record, options['alt-field'], None):
alt = record[options['alt-field']]
elif options.get('alt'):
alt = options['alt']
img = '<img class="%s" src="%s" style="%s"%s/>' % (classes, src, options.get('style', ''), ' alt="%s"' % alt if alt else '')
return ir_qweb.HTMLSafe(img)
评论列表
文章目录