Laravel : Image is Broken - image

i want to add two logo in the welcome page.i have stored the images in the folder named image under the public folder.In the build in homepage of Laravel i want to show these two images. i tried these
<image img src="C:\xampp\htdocs\officeapp\public\image\MB.png" alt="Logo"> </image>
<img src="{{URL::asset('/image/MB.png')}}" alt="logo" height="200" width="200">
but image is not showing only 'Logo' word is showing...what should i do?

Try this:
public_path() (Get the fully qualified path to the public directory.)
<img src="{{ public_path('/image/MB.png') }}" alt="logo" height="200" width="200">

try this one
<img href="{{ asset('/image/nashicon.ico') }}" />

Related

how to make the condition for the display of an image using laravel?

i did the loop to display images in blade, in my case it display empty image if image does not exist, then i want when the image does not exist it will display image whose name is not-found.jpg and whose root is img/not-found.jpg, if not it will display normal image.
<img src="{{ asset('storage/'.$annonce->image) }}" class="img-responsive" style="width: 240px;height: 240px" />
try this:
<img src="{{ !empty($annonce->image) ? asset('storage/'.$annonce->image) : asset('/img/not-found.jpg') }}" class="img-responsive" style="width: 240px;height: 240px" />

Image not found on <img src={{ asset(...) }}

This is my blade Looks like :
<img src="{{ asset('/assets/img/logo.png') }}" alt="logo" width="60px" height="60px">
And here's my folder structure
When i try to view the blade, its fine. But when i try to Export as PDF with Laravel-Excel, the error coming up
http://localhost:8000/assets/img/logo.png not found!
I already change asset() to url() and without laravel function but the error still coming, any suggestions?
Try this
{{ asset('assets/img/logo.png') }}
without the initial "/"
https://laravel.com/docs/8.x/helpers#method-asset
Have you try this
<img src="/assets/img/logo.png" alt="logo" width="60px" height="60px" />
OR
<img src="{{URL::asset('/assets/img/logo.png')}}" alt="logo" width="60px" height="60px" />
Please try these!
Solved
<img src="{{ public_path('assets/img/logo.png') }}" ... />

show Image that stored on filesystem

I've try many ways to show Image that stored on my FileSystem but not work. last i try with Intervention Image package, but it still not showing, just show icon blank image not the image itself.
This is my View:
<header>
<div style="text-align: center">
<h4>Detail Keluhan</h4><hr>
<h5 style="color: gray">{{$keluhan->username}}</h5>
<img src="{{ route('product.image', ['ttd_setuju' => $keluhan->ttd_setuju]) }}" alt="ttd_setuju"/>
</div>
</header>
This is my Route:
Route::get('image/{ttd_setuju}', ['as'=>'product.image', function($ttd_setuju) {
return Image::make('app/public/img/ttd'.'/'.$ttd_setuju)->response('png');
}]);
for information, i stored it on app/public/img/ttd
and it's name on table 'keluhan' in my DB
how can i solve this guys ? please kindly help any other way its okay if its work
So finally i fix the problem with this one
<img src="{{ asset('img/ttd/'.$keluhan->gambar) }}" height="200" width="250"/>
Using asset.

How display image in laravel 5.3

I store image in public folder now i want to display the image i give the path but image not show any one help me whats the wrong in my code
My image complete path is public/admin/product
<img src="public/admin/product/<?php echo $productr['image']; ?>" height="30px" width="30px">
First thing, you should not store those images inside public directory. Instead you should use Storage directory. Please have a look to the Laravel documentation:
https://laravel.com/docs/5.3/structure#the-storage-directory
So, upload such images inside "storage/app/public"
Then fire below artisan command to create symbolic link:
php artisan storage:link
And then create a link to that image:
<img src="{{ echo asset('storage/file.png') }}" height="30px" width="30px">
Laravel view files blade.php supports {{}} tags to display values.
{{ $valueToBeDisplayed }}
In your case, you can do like
<img src="/admin/product/{{ $product['image'] }}" height="30px" width="30px" />
Assuming image name is abc.png.
Make sure you have that image in folder public/admin/product/abc.png
remove public from your path.., also, you might have typos on the variable $productr, (did you mean $product?) try
<img src="admin/product/<?php echo $product['image']; ?>" height="30px" width="30px">
or, using blade standard:
<img src="admin/product/{{ $product['image']; }}" height="30px" width="30px">
#if ($productr['image'])
<img src="{{ asset('images/profile/'.$productr['image']) }}" alt="{{ $category->user->image }}">
#else
<img src="{{ asset('assets/dist/img/default-150x150.png') }}" >
#endif
<img src="{{storage/app/images/.($employee -> image)}}" width="50px">
"storage/app/images/" is the folder path to where your images are stored.
hope this will help
{{ asset('public/imagepath/image_name') }}

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?
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.
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">
Update After Laravel 5 this package has been deprecated and maintained as a separate external package. in order to work need to add this composer require laravelcollective/html. more details https://laravelcollective.com/
as of now, you can use
<img src="{{ asset('images/foo.png') }}" alt="tag">
In Laravel 5.x you can use laravelcollective/html and the syntax:
{!! Html::image('img/logo.png') !!}
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="">
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>****
In Laravel 5.x, you can also do like this .
<img class="img-responsive" src="{{URL::to('/')}}/img/stuvi-logo.png" alt=""/>
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">
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
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.

Resources