{{HTML::image}} 在 Laravel 中设置宽度和高度

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22577645/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:20:04  来源:igfitidea点击:

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

htmllaravellaravel-4

提问by user3384514

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我该怎么做?我试过:

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

But it doesn't seem to work.

但它似乎不起作用。

回答by darthmaim

It should work with

它应该与

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

The alt text comes before the attributes array.

替代文本出现在属性数组之前。

回答by Govind Samrow

In Laravel 5 following ways to use img in blade:

在 Laravel 5 中,可以通过以下方式在刀片中使用 img:

{!! 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",

注意:在使用 HTM 之前需要安装 laravel 库,即 "laravelcollective/html": "~5.0",

OR

或者

<img src="{!!asset('img/picture.jpg')!!}">

OR

或者

Set dynamically url:

动态设置网址:

<img src="{!!asset('img/').'/'.$imgsrc!!}">

回答by Mikke Baldonado

<img src="{{ asset('folder-name/pic_trulli.jpg')}}" class="img-fluid" style="min-width: 20px; min-height: 20px;">

回答by Ironheartbj18

you can

你可以

{{ HTML::image($product->image, $product->title, array('width' => '90%', 'height' => '50%')) }}

it required to be Apostrophe if create inside the percent.

如果在百分比内创建,它需要是撇号。

回答by Hashmat Waziri

Solution: store image path to your MYSQL table field. And dont forget the dot ( .) at the beginning of filepath.

解决方案:将图像路径存储到您的 MYSQL 表字段。并且不要忘记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.

你可以看到我是如何使用 twitter bootstrap 和其他属性的。

@foreach($imagefiles as $img)
<div class="col-xs-2 ">
  {{ $img->image_3}}
</div> 
@endforeach

回答by Abhishek Shukla

<img src='./images/bajja_huggy2.gif' class= img-responsive style= height: 22px; width: 100px; >