How to insert an image using Laravel's Blade 5.1

3

If I need to insert a css file or a script, I should do respectively:

<link href="{!! asset('css/style.css') !!}" type="text/css" />
<script type="text/javascript" src="{!! asset('js/app.js') !!}"></script>

On some sites, I've seen that something like this exists (when it was a dependency related to a specific library):

{{ HTML::image('img/picture.jpg') }}

Is there any way I can embed images within my HTML page directly in the scope of the blade file without having to go to external libraries?

My intention is actually to insert SVG files and I know that if you can insert any .jpeg it should also be possible to insert a .svg .

    
asked by anonymous 07.12.2015 / 02:13

2 answers

0

Thanks @gmsantos but incredible as it seems laravel did not accept that I used the tag public_path and for laravel 5.1 it worked perfectly as a simple reference like this:

<img src="{!! asset('img/logomarca-c.svg') !!}">

Note: The use of the {{}} denotation is being deprecated, and at laravel 5.1 the blade is already starting to change its references to {!! !!}

    
08.12.2015 / 00:28
1

The HTML component has been removed since Laravel 5 from the framework core.

You need to include Laravel Collective if you want to use {{ HTML::image('img/picture.jpg') }} or use HTML directly:

<img src="{{ public_path('img/picture.jpg') }}">
    
07.12.2015 / 05:21