Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

{{HTML::image}} set width and height in Laravel

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.

like image 607
user3384514 Avatar asked Mar 22 '14 12:03

user3384514


People also ask

How do I set the same width and height of an image in HTML?

container img { width: 100%; height: 400px; //this should be the same as the width value.. }

Why should you include the width and height attributes of an image in the img /> tag?

The purpose of the height (and the width attribute as well) is to inform the browser of the actual size of the image as it appears in the file — not as it is intended to appear in the design of the page.


3 Answers

It should work with

{{ HTML::image('path', 'alt', array( 'width' => 70, 'height' => 70 )) }}

The alt text comes before the attributes array.

like image 175
darthmaim Avatar answered Oct 19 '22 09:10

darthmaim


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!!}">
like image 22
Govind Samrow Avatar answered Oct 19 '22 10:10

Govind Samrow


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
like image 1
Hashmat Waziri Avatar answered Oct 19 '22 09:10

Hashmat Waziri