@@ -209,7 +200,7 @@
-
![]()
+
diff --git a/addons/web_editor/static/tests/test_utils.js b/addons/web_editor/static/tests/test_utils.js
index 27ba86b52ff..7d2a4b37bbb 100644
--- a/addons/web_editor/static/tests/test_utils.js
+++ b/addons/web_editor/static/tests/test_utils.js
@@ -347,14 +347,21 @@ function wysiwygData(data) {
string: "res_model",
type: 'char',
},
+ public: {
+ string: "public",
+ type: 'boolean',
+ },
access_token: {
string: "access_token",
type: 'char',
},
+ image_src: {
+ string: "image_src",
+ type: 'char',
+ },
},
records: [{
id: 1,
- public: true,
name: 'image',
datas_fname: 'image.png',
mimetype: 'image/png',
@@ -363,7 +370,9 @@ function wysiwygData(data) {
type: 'url',
res_id: 0,
res_model: false,
- access_token: false
+ public: true,
+ access_token: false,
+ image_src: '/web_editor/static/src/img/transparent.png',
}],
generate_access_token: function () {
return;
diff --git a/addons/web_editor/static/tests/wysiwyg_tests.js b/addons/web_editor/static/tests/wysiwyg_tests.js
index be62dbb4192..e03fb3888fb 100644
--- a/addons/web_editor/static/tests/wysiwyg_tests.js
+++ b/addons/web_editor/static/tests/wysiwyg_tests.js
@@ -3378,28 +3378,6 @@ var altDialogSaved;
var cropDialogOpened;
QUnit.module('Media', {
beforeEach: function () {
- $('body').on('submit.WysiwygTests', function (ev) {
- ev.preventDefault();
- var $from = $(ev.target);
- var iframe = $from.find('iframe[name="' + $from.attr('target') + '"]')[0];
- if (iframe) {
- iframe.contentWindow.attachments = [{
- id: 1,
- public: true,
- name: 'image',
- datas_fname: 'image.png',
- mimetype: 'image/png',
- checksum: false,
- url: '/web_editor/static/src/img/transparent.png',
- type: 'url',
- res_id: 0,
- res_model: false,
- access_token: false
- }];
- $(iframe).trigger('load');
- }
- });
-
this.data = {
debug: false,
wysiwygOptions: {
@@ -3415,6 +3393,21 @@ QUnit.module('Media', {
if (route.indexOf('/web_editor/static/src/img/') === 0) {
return Promise.resolve();
}
+ if (route === '/web_editor/attachment/add_url') {
+ return Promise.resolve({
+ id: 1,
+ public: true,
+ name: 'image',
+ mimetype: 'image/png',
+ checksum: false,
+ url: '/web_editor/static/src/img/transparent.png',
+ image_src: '/web_editor/static/src/img/transparent.png',
+ type: 'url',
+ res_id: 0,
+ res_model: false,
+ access_token: false,
+ });
+ }
return this._super(route, args);
},
};
diff --git a/addons/web_unsplash/controllers/main.py b/addons/web_unsplash/controllers/main.py
index c9a2deb631e..98b3cec976e 100644
--- a/addons/web_unsplash/controllers/main.py
+++ b/addons/web_unsplash/controllers/main.py
@@ -97,7 +97,7 @@ class Web_Unsplash(http.Controller):
logger.exception("Timeout: " + str(e))
continue
- image_base64 = tools.image_process(image_base64)
+ image_base64 = tools.image_process(image_base64, verify_resolution=True)
mimetype = guess_mimetype(base64.b64decode(image_base64))
# append image extension in name
query += mimetypes.guess_extension(mimetype) or ''
@@ -116,7 +116,7 @@ class Web_Unsplash(http.Controller):
'res_model': res_model,
})
attachment.generate_access_token()
- uploads.extend(attachment.read(['name', 'mimetype', 'checksum', 'url', 'type', 'res_id', 'res_model', 'access_token']))
+ uploads.append(attachment._get_media_info())
# Notifies Unsplash from an image download. (API requirement)
self._notify_download(value.get('download_url'))
diff --git a/addons/web_unsplash/static/src/js/unsplash_image_widget.js b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
index 53259e6278b..8244f12b4b9 100644
--- a/addons/web_unsplash/static/src/js/unsplash_image_widget.js
+++ b/addons/web_unsplash/static/src/js/unsplash_image_widget.js
@@ -92,10 +92,6 @@ widgetsMedia.ImageWidget.include({
query: self._unsplash.query,
}
}).then(function (images) {
- _.each(images, function (image) {
- image.src = image.url;
- image.isDocument = !(/gif|jpe|jpg|png/.test(image.mimetype));
- });
self.attachments = images;
self.selectedAttachments = images;
return _super.apply(self, args);
diff --git a/addons/website/static/src/js/editor/snippets.options.js b/addons/website/static/src/js/editor/snippets.options.js
index eb7f014307a..2798ca38f5c 100644
--- a/addons/website/static/src/js/editor/snippets.options.js
+++ b/addons/website/static/src/js/editor/snippets.options.js
@@ -1008,7 +1008,7 @@ options.registry.gallery = options.Class.extend({
for (var i = 0 ; i < attachments.length; i++) {
$('
![]()
', {
class: 'img img-fluid',
- src: attachments[i].src,
+ src: attachments[i].image_src,
'data-index': ++index,
}).appendTo($container);
}
diff --git a/odoo/fields.py b/odoo/fields.py
index 8baf2fa2edd..cc2932ef899 100644
--- a/odoo/fields.py
+++ b/odoo/fields.py
@@ -1817,7 +1817,7 @@ class Binary(Field):
return None
# Detect if the binary content is an SVG for restricting its upload
# only to system users.
- if value[:1] == b'P': # Fast detection of first 6 bits of '<' (0x3C)
+ if value[:1] in (b'P', 'P'): # Fast detection of first 6 bits of '<' (0x3C)
decoded_value = base64.b64decode(value)
# Full mimetype detection
if (guess_mimetype(decoded_value).startswith('image/svg') and
diff --git a/odoo/tools/image.py b/odoo/tools/image.py
index c714d912eb9..6f02f3c3d65 100644
--- a/odoo/tools/image.py
+++ b/odoo/tools/image.py
@@ -60,7 +60,7 @@ class ImageProcess():
self.base64_source = base64_source or False
self.operationsCount = 0
- if not base64_source or base64_source[:1] == b'P':
+ if not base64_source or base64_source[:1] in (b'P', 'P'):
# don't process empty source or SVG
self.image = False
else:
@@ -318,7 +318,7 @@ def is_image_size_above(base64_source, size=IMAGE_BIG_SIZE):
"""
if not base64_source:
return False
- if base64_source[:1] == b'P':
+ if base64_source[:1] in (b'P', 'P'):
# False for SVG
return False
image = base64_to_image(base64_source)