Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Define a default image if the variable {{image}} is empty

My <img>:

<img width="90" height="90"  src="{{image}}" />

Default image folder: assets/img/pic_user.png

How can I define a default image that is not defined in the variable: {{image}} ?

like image 760
viana Avatar asked Aug 12 '26 00:08

viana


1 Answers

Use Logical OR operator ||

<img width="90" height="90"  src="{{image||'assets/img/pic_user.png'}}" />
like image 199
Avinash Raj Avatar answered Aug 13 '26 13:08

Avinash Raj



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!