Use {{asset ()}} in an echo


I have the following problem:

I need to make a query of images saved on the server to show them in a view

 echo "<img src={{asset ('images/producto/{$producto->imagen}'}} title='{$producto->imagen}'/>";
asked by harriroot 05.10.2016 в 19:28

1 answer


What Blade does in this case is nothing more than a kind of echo, therefore it would be redundant what you are doing (echo within another echo), something like this should work:

<img src={{ asset('images/producto/' . $producto->imagen) }} title='{{ $producto->imagen }}' />

I assume you are in a blade view for which I use the PHP style in HTML (and not the other way around as you were doing).

answered by 05.10.2016 / 19:55