Laravel Blade html 图像

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29858097/
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-09-08 16:58:47  来源:igfitidea点击:

Laravel Blade html image

laravelimagelaravel-blade

提问by patels326

My image file path is public/img/logo.pngand
my app.blade.php file path is resources/views/app.blade.php

我的图像文件路径是public/img/logo.png
我的 app.blade.php 文件路径是resources/views/app.blade.php

Inside of my app.blade.php file I use {{HTML::image('/img/stuvi-logo.png')}}
to display an image.
I don't understand why this won't find the image.
What is the root folder of the image()method?

在我的 app.blade.php 文件中,我{{HTML::image('/img/stuvi-logo.png')}}
用来显示图像。
我不明白为什么这不会找到图像。
image()方法的根文件夹是什么?

采纳答案by Alupotha

Change/img/stuvi-logo.pngtoimg/stuvi-logo.png

更改/img/stuvi-logo.pngimg/stuvi-logo.png

{{ HTML::image('img/stuvi-logo.png', 'alt text', array('class' => 'css-class')) }}

Which produces the following HTML.

它产生以下 HTML

<img src="http://your.url/img/stuvi-logo.png" class="css-class" alt="alt text">

回答by Erfan Ahmed

If you use bootstrap, you might use this -

如果您使用引导程序,您可以使用这个 -

 <img src="{{URL::asset('/image/propic.png')}}" alt="profile Pic" height="200" width="200">

note: inside publicfolder create a new folder named imagethen put your images there. Using URL::asset()you can directly access to the publicfolder.

注意:在public文件夹中创建一个名为image的新文件夹,然后将您的图像放在那里。使用URL::asset()您可以直接访问公共文件夹。

回答by Dylan

In Laravel 5.x you can use laravelcollective/htmland the syntax:

在 Laravel 5.x 中你可以使用laravelcollective/html和语法:

{!! Html::image('img/logo.png') !!}

回答by Magige Daniel

Had the same problem with laravel 5.3... This is how I did it and very easy. for example logo in the blade page view

与laravel有同样的问题5.3 ..。我就是这样做的,而且非常简单。例如刀片页面视图中的徽标

****<image img src="/img/logo.png" alt="Logo"></image>****

回答by Palistha

In Laravel 5.x, you can also do like this .

在 Laravel 5.x 中,你也可以这样做。

<img class="img-responsive" src="{{URL::to('/')}}/img/stuvi-logo.png" alt=""/>

<img class="img-responsive" src="{{URL::to('/')}}/img/stuvi-logo.png" alt=""/>