diff --git a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js index c2a7d8f1ae3..5fb93b53c54 100644 --- a/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js +++ b/addons/web_editor/static/src/js/wysiwyg/wysiwyg.js @@ -1153,7 +1153,7 @@ export class Wysiwyg extends Component { */ savePendingImages($editable = this.$editable) { const defs = Array.from($editable).map(async (editableEl) => { - const {oeModel: resModel, oeId: resId} = editableEl.dataset; + const {res_model: resModel, res_id: resId} = this.options.recordInfo; // When saving a webp, o_b64_image_to_save is turned into // o_modified_image_to_save by _saveB64Image to request the saving // of the pre-converted webp resizes and all the equivalent jpgs. @@ -2926,6 +2926,8 @@ export class Wysiwyg extends Component { name: el.dataset.fileName || '', data: el.getAttribute('src').split(',')[1], is_image: true, + res_model: resModel, + res_id: resId, }, ); if (attachment.mimetype === 'image/webp') { @@ -2935,7 +2937,19 @@ export class Wysiwyg extends Component { el.dataset.fileName = attachment.name; this._saveModifiedImage(el, resModel, resId); } else { - el.setAttribute('src', attachment.image_src); + let src = attachment.image_src; + if (!attachment.public) { + let accessToken = attachment.access_token; + if (!accessToken) { + [accessToken] = await this.orm.call( + 'ir.attachment', + 'generate_access_token', + [attachment.id], + ); + } + src += `?access_token=${encodeURIComponent(accessToken)}`; + } + el.setAttribute('src', src); } el.classList.remove('o_b64_image_to_save'); }