Skip to Content
Menu
You need to be registered to interact with the community.
This question has been flagged
3 Odgovori
18223 Prikazi

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?


Avatar
Opusti
Best Answer

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>
Avatar
Opusti
Best Answer

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;"/>
Avatar
Opusti
Best Answer

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;"/> 



Avatar
Opusti
Related Posts Odgovori Prikazi Aktivnost
2
avg. 20
3637
1
jan. 19
7998
0
dec. 24
549
0
dec. 24
506
2
jul. 24
1926