[FIX] website, website_sale: alternative for images
Images should have an alternative (the "alt" attribute") in order to be W3C compliant (accessibility). opw-648135
This commit is contained in:
parent
399cbc7522
commit
ed214a6681
|
@ -298,7 +298,12 @@ class Image(orm.AbstractModel):
|
|||
max_size = '%sx%s' % (max_width, max_height)
|
||||
|
||||
src = self.pool['website'].image_url(cr, uid, record, field_name, max_size)
|
||||
img = '<img class="%s" src="%s" style="%s"/>' % (classes, src, options.get('style', ''))
|
||||
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)
|
||||
|
||||
local_url_re = re.compile(r'^/(?P<module>[^]]+)/static/(?P<rest>.+)$')
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
</div>
|
||||
<div class="oe_product_image">
|
||||
<a itemprop="url" t-att-href="keep('/shop/product/%s' % slug(product), page=(pager['page']['num'] if pager['page']['num']>1 else None))">
|
||||
<img itemprop="image" class="img img-responsive" t-att-src="website.image_url(product, 'image', None if product_image_big else '300x300')"/>
|
||||
<img itemprop="image" class="img img-responsive" t-att-src="website.image_url(product, 'image', None if product_image_big else '300x300')" t-att-alt="product.name"/>
|
||||
</a>
|
||||
</div>
|
||||
<section>
|
||||
|
@ -368,7 +368,7 @@
|
|||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-7 col-md-7 col-lg-7">
|
||||
<span itemprop="image" t-field="product.image" t-field-options='{"widget": "image", "class": "product_detail_img"}'/>
|
||||
<span itemprop="image" t-field="product.image" t-field-options='{"widget": "image", "class": "product_detail_img", "alt-field": "name"}'/>
|
||||
</div><div class="col-sm-5 col-md-5 col-lg-4 col-lg-offset-1">
|
||||
<h1 itemprop="name" t-field="product.name">Product Name</h1>
|
||||
<span itemprop="url" style="display:none;" t-esc="'/shop/product/%s' % slug(product)"/>
|
||||
|
|
Loading…
Reference in New Issue