Skip to Content
Меню
Вам необхідно зареєструватися, щоб взаємодіяти зі спільнотою.
Це запитання позначене
3 Відповіді
18995 Переглядів

I'm trying to put an image sotred in my custom module in /static/src/img/ and i found that the supossed correct way is with <img class="img img-responsive" src="/my_module/static/src/img/my_image.png"/>

But the image is not showing at all, i also tried with the absolute path but still not working, this is the part of the template im working on:

<img t-if="obj.company_id.extra_logo"
class="img" style="max-width: 40mm; max-height: 20mm;"
t-att-src="'data:image/png;base64,%s' % obj.company_id.extra_logo"/>
<img t-if="not obj.company_id.extra_logo"
class="img" style="max-width: 40mm; max-height: 20mm;"
src="/extra_reports/static/src/img/default_logo.png"/>

** I tried without the t-if condition for the second image, but in any case a small square is showed, representing the image without the image itself.

What i'm doing wrong?


Аватар
Відмінити
Найкраща відповідь

Hello 

try below code,

<t t-if="obj.company_id.extra_logo">
<img t-att-src="'data:image/png;base64,%s' % to_text(obj.company_id.extra_logo)" style="max-height:1cm; max-width:4cm;"/>
</t>
Аватар
Відмінити
Найкраща відповідь

Hello

You can try below code i think it's help you

<img t-if="obj.company_id.extra_logo"
t-att-src="'data:image/png;base64,%s' % obj.company_id.extra_logo"
style="max-width: 40px; max-height: 20px;"/>
Аватар
Відмінити
Найкраща відповідь

hey try this

store your image in web/static/src/img

<img src="http://localhost:8069/web/static/src/img/your_logo.jpg" width="180" height="150" />

you can also try this

<img t-attf-src="data:image/*;base64,{{company.logo}}" t-att-alt="company.name" style="max-height: 100px;"/> 



Аватар
Відмінити
Related Posts Відповіді Переглядів Дія
2
серп. 20
4079
1
січ. 19
8669
0
груд. 24
1214
0
груд. 24
1024
2
лип. 24
2941