summaryrefslogtreecommitdiff
path: root/addons/web_editor/models
diff options
context:
space:
mode:
authorSamuel Degueldre <sad@odoo.com>2020-03-24 13:34:17 +0000
committerSamuel Degueldre <sad@odoo.com>2020-03-30 11:06:48 +0000
commit49ea7b2b413dfcb2290b02eee4b43bfdabd535b2 (patch)
tree0b07f2a364b5d151053dfde9024d80f585573072 /addons/web_editor/models
parent25630e442129e98a78e790949a471e5eceb9a843 (diff)
[IMP] web_editor: improve image optimization workflow in media dialog
Previously, when selecting an image, the user could optimize their images by clicking a little cog icon in the media dialog. They would also be prompted to optimize their images when uploading them. In most cases, it makes a lot more sense to always save the original in the database, and optimize the original whenever it's dropped in the page automatically. A second problem is that when using the optimization feature, optimized images would be displayed along the originals by default, resulting in a lot of duplicates while browsing the media dialog. This commit changes both of these things: - By default, when uploading an image, the original uploaded image is used. The user can still optimize their image manually through the media-dialog by using the cog icon. When choosing an image in the media-dialog, if it's not already an optimized image, an optimized copy is automatically created and used instead. - Optimized images are now hidden by default, in the media dialog, and can be shown by clicking a checkbox at the top of the modal when in debug mode task-2091417 closes odoo/odoo#45174
Diffstat (limited to 'addons/web_editor/models')
-rw-r--r--addons/web_editor/models/ir_attachment.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/addons/web_editor/models/ir_attachment.py b/addons/web_editor/models/ir_attachment.py
index 7c8ff486ea6..36c44320c48 100644
--- a/addons/web_editor/models/ir_attachment.py
+++ b/addons/web_editor/models/ir_attachment.py
@@ -14,6 +14,7 @@ class IrAttachment(models.Model):
image_src = fields.Char(compute='_compute_image_src')
image_width = fields.Integer(compute='_compute_image_size')
image_height = fields.Integer(compute='_compute_image_size')
+ original_id = fields.Many2one('ir.attachment', string="Original (unoptimized, unresized) attachment")
def _compute_local_url(self):
for attachment in self:
@@ -47,4 +48,4 @@ class IrAttachment(models.Model):
def _get_media_info(self):
"""Return a dict with the values that we need on the media dialog."""
self.ensure_one()
- return self.read(['id', 'name', 'mimetype', 'checksum', 'url', 'type', 'res_id', 'res_model', 'public', 'access_token', 'image_src', 'image_width', 'image_height'])[0]
+ return self._read_format(['id', 'name', 'mimetype', 'checksum', 'url', 'type', 'res_id', 'res_model', 'public', 'access_token', 'image_src', 'image_width', 'image_height', 'original_id'])[0]