summaryrefslogtreecommitdiff
path: root/addons/website/static/src/snippets
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-02-26 11:58:27 +0000
committerSamuel Degueldre <sad@odoo.com>2020-03-30 11:07:10 +0000
commit807ac811446836925092b7214fec004ef4ef4ca8 (patch)
treef259401bc6ce867555dc63643df8eb7f283068b6 /addons/website/static/src/snippets
parent02e71a1a3c2ec1446210cddfa0e08840bea7fde6 (diff)
[IMP] web_editor, *: set image alt automatically, remove useless alts
*: website, web_unplash The html alt attribute is supposed to contain a description of an image's content (an alternative to the visual representation), a lot of snippets contained alt attributes that were not descriptive of their content, and would as such be counter-productive in terms of accessibility. This commit removes those. Previously, the alt attribute on img tags had to be set manually by the user through the editor. This commit makes use of the description field on ir.attachment to store image description, and sets the alt attribute on images to that description when choosing an image from the media dialog. task-2091417 closes odoo/odoo#45174 Related: odoo/enterprise#9520 Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com>
Diffstat (limited to 'addons/website/static/src/snippets')
-rw-r--r--addons/website/static/src/snippets/s_image_gallery/options.js10
1 files changed, 6 insertions, 4 deletions
diff --git a/addons/website/static/src/snippets/s_image_gallery/options.js b/addons/website/static/src/snippets/s_image_gallery/options.js
index 52fedd2c3a6..6ce339b2d77 100644
--- a/addons/website/static/src/snippets/s_image_gallery/options.js
+++ b/addons/website/static/src/snippets/s_image_gallery/options.js
@@ -94,6 +94,7 @@ options.registry.gallery = options.Class.extend({
class: 'img img-fluid',
src: attachments[i].image_src,
'data-index': ++index,
+ alt: attachments[i].description || '',
}).appendTo($container);
}
this.mode('reset', this.getMode());
@@ -254,12 +255,13 @@ options.registry.gallery = options.Class.extend({
*/
slideshow: function () {
var imgStyle = this.$el.find('.active[data-styling]').data('styling') || '';
- var urls = _.map(this._getImages(), function (img) {
- return $(img).attr('src');
- });
+ var images = _.map(this._getImages(), img => ({
+ src: img.getAttribute('src'),
+ alt: img.getAttribute('alt'),
+ }));
var currentInterval = this.$target.find('.carousel:first').attr('data-interval');
var params = {
- srcs: urls,
+ images: images,
index: 0,
title: "",
interval: currentInterval || this.$target.data('interval') || 0,