'Laravel Blade html image
My image file path is public/img/stuvi-logo.png
and
my app.blade.php file path is 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?
Solution 1:[1]
Change /img/stuvi-logo.png
to img/stuvi-logo.png
{{ HTML::image('img/stuvi-logo.png', 'alt text', array('class' => 'css-class')) }}
Which produces the following HTML.
<img src="http://your.url/img/stuvi-logo.png" class="css-class" alt="alt text">
Solution 2:[2]
If you use bootstrap, you might use this -
<img src="{{URL::asset('/image/propic.png')}}" alt="profile Pic" height="200" width="200">
note: inside public folder create a new folder named image then put your images there. Using URL::asset()
you can directly access to the public folder.
Solution 3:[3]
as of now, you can use
<img src="{{ asset('images/foo.png') }}" alt="tag">
Solution 4:[4]
In Laravel 5.x you can use laravelcollective/html and the syntax:
{!! Html::image('img/logo.png') !!}
Solution 5:[5]
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
****<image img src="/img/logo.png" alt="Logo"></image>****
Solution 6:[6]
In Laravel 5.x, you can also do like this .
<img class="img-responsive" src="{{URL::to('/')}}/img/stuvi-logo.png" alt=""/>
Solution 7:[7]
you can Using asset() you can directly access to the image folder.
<img src="{{asset('img/stuvi-logo.png')}}" alt="logo" class="img-size-50 mr-3 img-circle">
Solution 8:[8]
It will look for an image inside of a public/storage folder where you can define your own image folder
<img src="{{ Storage::url($post->image->path) }}" alt="">
Always try to dump what you are looking for first and than pass it to a url method.
Also, you can create your own url() method inside your Image model if you have some
public function url()
{
return Storage::url($this->path);
}
Then in your blade template you can use this method as follows:
<img src="{{ $post->image->url() }}" alt="">
Solution 9:[9]
in my case this worked perfectly
<img style="border-radius: 50%;height: 50px;width: 80px;" src="<?php echo asset("storage/TeacherImages/{$studydata->teacher->profilePic}")?>">
this code is used to display image from folder
Solution 10:[10]
Assuming the file you want to display is public try adding the variable in your Mail builder function.
public function toMail($notifiable)
{
$img_url = env('APP_URL')."/img/stuvi-logo.png";
return (new MailMessage)
->subject('Test')
->markdown('vendor.mail.markdown.message', [
'data' => $this->data,
'img_url'=>$img_url
]);
}
And then use your 'img_url' variable set in the array in your email blade file.
< img src={{img_url}} alt="Logo" height="50"/>
This worked for me on Laravel 8.xx.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | |
Solution 3 | Anthony Meinder |
Solution 4 | |
Solution 5 | Magige Daniel |
Solution 6 | |
Solution 7 | yassine dotma |
Solution 8 | |
Solution 9 | Mohsin G |
Solution 10 | Mocktar Issa |