[FIX] web: clear filename if image error

When the user chooses as product image a file which is not an image, the
message "Could not display the selected image" is displayed. However, at
saving, a traceback is thrown since the file chosen is uploaded anyway.

If the image cannot be displayed, the image field is cleared.

opw-672206
This commit is contained in:
Nicolas Martinelli 2016-03-24 11:18:14 +01:00
parent 3bc7ea6bcf
commit f1b9b301da
1 changed files with 1 additions and 0 deletions

View File

@ -5229,6 +5229,7 @@ instance.web.form.FieldBinaryImage = instance.web.form.FieldBinary.extend({
$img.css("margin-top", "" + (self.options.size[1] - $img.height()) / 2 + "px");
});
$img.on('error', function() {
self.on_clear();
$img.attr('src', self.placeholder);
instance.webclient.notification.warn(_t("Image"), _t("Could not display the selected image."));
});