mirror of https://github.com/OCA/web.git
Merge pull request #1145 from anandkansagra/12.0-mig-web_widget_image_url
[12.0] [MIG] web_widget_image_urlpull/1310/head
commit
3d19b979a4
|
@ -0,0 +1,56 @@
|
||||||
|
.. image:: https://www.gnu.org/graphics/lgplv3-147x51.png
|
||||||
|
:target: https://www.gnu.org/licenses/lgpl-3.0.en.html
|
||||||
|
:alt: License: LGPL-v3
|
||||||
|
|
||||||
|
=============
|
||||||
|
Web Image URL
|
||||||
|
=============
|
||||||
|
|
||||||
|
This module provides web widget for displaying image from URL on form and tree views.
|
||||||
|
|
||||||
|
Usage
|
||||||
|
=====
|
||||||
|
|
||||||
|
To use this module, you need to decorate xml field with widget ``image_url``.
|
||||||
|
|
||||||
|
|
||||||
|
.. code-block:: xml
|
||||||
|
|
||||||
|
<field name="avatar" widget="image_url" class="oe_image_small" width="100px" height="100px"/>
|
||||||
|
|
||||||
|
Here's an examples of how images looks like on a form
|
||||||
|
|
||||||
|
.. figure:: static/description/image.png
|
||||||
|
|
||||||
|
Bug Tracker
|
||||||
|
===========
|
||||||
|
|
||||||
|
Bugs are tracked on `GitHub Issues
|
||||||
|
<https://github.com/OCA/web/issues>`_. In case of trouble, please
|
||||||
|
check there if your issue has already been reported. If you spotted it first,
|
||||||
|
help us smash it by providing detailed and welcomed feedback.
|
||||||
|
|
||||||
|
Credits
|
||||||
|
=======
|
||||||
|
|
||||||
|
Contributors
|
||||||
|
------------
|
||||||
|
|
||||||
|
* Petar Najman <petar.najman@modoolar.com>
|
||||||
|
* Sladjan Kantar <sladjan.kantar@modoolar.com>
|
||||||
|
* Anand Kansagra <kansagraanand@hotmail.com>
|
||||||
|
|
||||||
|
Maintainer
|
||||||
|
----------
|
||||||
|
|
||||||
|
.. image:: https://odoo-community.org/logo.png
|
||||||
|
:alt: Odoo Community Association
|
||||||
|
:target: https://odoo-community.org
|
||||||
|
|
||||||
|
This module is maintained by the OCA.
|
||||||
|
|
||||||
|
OCA, or the Odoo Community Association, is a nonprofit organization whose
|
||||||
|
mission is to support the collaborative development of Odoo features and
|
||||||
|
promote its widespread use.
|
||||||
|
|
||||||
|
To contribute to this module, please visit https://odoo-community.org.
|
|
@ -0,0 +1 @@
|
||||||
|
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
|
@ -0,0 +1,17 @@
|
||||||
|
# Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||||
|
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
||||||
|
{
|
||||||
|
"name": "Web Image URL",
|
||||||
|
"summary": "This module provides web widget for displaying image from URL",
|
||||||
|
"category": "Web",
|
||||||
|
"version": "12.0.1.0.0",
|
||||||
|
"license": "LGPL-3",
|
||||||
|
"author": "Modoolar, Odoo Community Association (OCA)",
|
||||||
|
"website": "https://github.com/OCA/web/",
|
||||||
|
"depends": ["web"],
|
||||||
|
"data": [
|
||||||
|
"views/web_widget_image_url.xml",
|
||||||
|
],
|
||||||
|
"qweb": ["static/src/xml/*.xml"],
|
||||||
|
"installable": True,
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
# Translation of Odoo Server.
|
||||||
|
# This file contains the translation of the following modules:
|
||||||
|
# * web_widget_image_url
|
||||||
|
#
|
||||||
|
msgid ""
|
||||||
|
msgstr ""
|
||||||
|
"Project-Id-Version: Odoo Server 11.0\n"
|
||||||
|
"Report-Msgid-Bugs-To: \n"
|
||||||
|
"Last-Translator: <>\n"
|
||||||
|
"Language-Team: \n"
|
||||||
|
"MIME-Version: 1.0\n"
|
||||||
|
"Content-Type: text/plain; charset=UTF-8\n"
|
||||||
|
"Content-Transfer-Encoding: \n"
|
||||||
|
"Plural-Forms: \n"
|
||||||
|
|
||||||
|
#. module: web_widget_image_url
|
||||||
|
#. openerp-web
|
||||||
|
#: code:addons/web_widget_image_url/static/src/js/web_widget_image_url.js:30
|
||||||
|
#, python-format
|
||||||
|
msgid "Could not display the selected image."
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#. module: web_widget_image_url
|
||||||
|
#. openerp-web
|
||||||
|
#: code:addons/web_widget_image_url/static/src/js/web_widget_image_url.js:30
|
||||||
|
#, python-format
|
||||||
|
msgid "Image"
|
||||||
|
msgstr ""
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
* Petar Najman <petar.najman@modoolar.com>
|
||||||
|
* Sladjan Kantar <sladjan.kantar@modoolar.com>
|
||||||
|
* Anand Kansagra <kansagraanand@hotmail.com>
|
|
@ -0,0 +1 @@
|
||||||
|
This module provides web widget for displaying image from URL on form and tree views.
|
|
@ -0,0 +1 @@
|
||||||
|
To use this module, you need to decorate xml field with widget ``image_url``.
|
Binary file not shown.
After Width: | Height: | Size: 9.2 KiB |
Binary file not shown.
After Width: | Height: | Size: 18 KiB |
|
@ -0,0 +1,36 @@
|
||||||
|
// Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||||
|
// License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
||||||
|
|
||||||
|
odoo.define('web_widget_image_url.FieldImageURL', function (require) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var AbstractField = require('web.AbstractField');
|
||||||
|
var core = require('web.core');
|
||||||
|
var registry = require('web.field_registry');
|
||||||
|
var _t = core._t;
|
||||||
|
|
||||||
|
var UrlImage = AbstractField.extend({
|
||||||
|
className: 'o_attachment_image',
|
||||||
|
template: 'FieldImageURL',
|
||||||
|
placeholder: "/web/static/src/img/placeholder.png",
|
||||||
|
supportedFieldTypes: ['char'],
|
||||||
|
|
||||||
|
url: function () {
|
||||||
|
return this.value ? this.value : this.placeholder;
|
||||||
|
},
|
||||||
|
|
||||||
|
_render: function () {
|
||||||
|
this._super(arguments);
|
||||||
|
|
||||||
|
var self = this;
|
||||||
|
var $img = this.$("img:first");
|
||||||
|
$img.on('error', function () {
|
||||||
|
$img.attr('src', self.placeholder);
|
||||||
|
self.do_warn(
|
||||||
|
_t("Image"), _t("Could not display the selected image."));
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
registry.add('image_url', UrlImage);
|
||||||
|
});
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
# Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||||
|
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
||||||
|
-->
|
||||||
|
<templates xml:space="preserve">
|
||||||
|
<t t-name="FieldImageURL">
|
||||||
|
<span class="oe_form_field oe_form_field_image" t-att-style="widget.attrs.style">
|
||||||
|
<img t-att-src="widget.url()"
|
||||||
|
t-att-style="(!widget.readonly ? 'border: 0' : 'border: 1')"
|
||||||
|
t-att-name="widget.name"
|
||||||
|
t-att-width="widget.attrs.img_width || widget.attrs.width"
|
||||||
|
t-att-height="widget.attrs.img_height || widget.attrs.height"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
|
</t>
|
||||||
|
</templates>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!--
|
||||||
|
# Copyright 2017 - 2018 Modoolar <info@modoolar.com>
|
||||||
|
# License LGPLv3.0 or later (https://www.gnu.org/licenses/lgpl-3.0.en.html).
|
||||||
|
-->
|
||||||
|
<odoo>
|
||||||
|
<template id="assets_backend" name="web_widget_image_url assets" inherit_id="web.assets_backend">
|
||||||
|
<xpath expr="." position="inside">
|
||||||
|
<script type="text/javascript" src="/web_widget_image_url/static/src/js/web_widget_image_url.js" />
|
||||||
|
</xpath>
|
||||||
|
</template>
|
||||||
|
</odoo>
|
Loading…
Reference in New Issue