{{HTML::image}} set width and height in Laravel
32,885
Solution 1
It should work with
{{ HTML::image('path', 'alt', array( 'width' => 70, 'height' => 70 )) }}
The alt text comes before the attributes array.
Solution 2
In Laravel 5 following ways to use img in blade:
{!! HTML::image('img/picture.jpg', 'a picture', array('class' => 'thumb')) !!}
Note: you need to install laravel library before use HTM i.e "laravelcollective/html": "~5.0",
OR
<img src="{!!asset('img/picture.jpg')!!}">
OR
Set dynamically url:
<img src="{!!asset('img/').'/'.$imgsrc!!}">
Solution 3
Solution : store image path to your MYSQL table field. And dont forget the dot ( . ) at the beginning of filepath.
<img src='./images/bajja_huggy2.gif' class= img-responsive style= height: 22px; width: 100px; >
you can see how I have used twitter bootstrap and other properties.
@foreach($imagefiles as $img)
<div class="col-xs-2 ">
{{ $img->image_3}}
</div>
@endforeach
Author by
user3384514
Updated on July 30, 2022Comments
-
user3384514 over 1 year
Sorry for the stupid question, but I looked everywhere in the doc. If I want to set size, height and width of an image with
HTML::image
, how can I do it? I tried with:{{ HTML::image('path', array('width' => 70 , 'height' => 70)); }}
But it doesn't seem to work.
-
Bielco about 10 yearsThat's correct, from the api... string image(string $url, string $alt = null, array $attributes = array(), bool $secure = null) Generate an HTML image element.
-
user3384514 about 10 yearssorry, i didn't know that alt couldn't be null
-
darthmaim about 10 yearsalt can be null, but attributes still has to be the 3rd parameter. So if you dont want to specify alt (you should always), you can write
HTML::image('path',null,$attr)
. -
Luís Cruz about 9 yearsThe OP expected an answer that uses Laravel code. Although yours is correct, it doesn't use Laravel. Besides this excerpt is an exact copy of is an exact copy of user2592890's answer.