adding images to laravel blades - laravel

I m facing strange issue in laravel.
on my local serve it is not accessing this image
http://localhost:8000/img/logo.png
but I can acess this image
http://localhost:8000/img/profile.png
mover over it is not show in code as well any ideas.

Try
<img src="{{ url('img/yourimage.png') }}" alt="">
It will grab the image from your project public folder. It will look like yourwebsite.com/img/yourimage.png and in local server it will look like
http://localhost:8000/img/yourimage.png
2nd Solution:
Try
{{ Html::image('yourimage.png') }}

in laravel there is a inbuilt function url() which is used to ge the path from the public folder of your project. So to show image in your view you can use:
<img src="{{ url('img/yourimage.png') }}" alt="No image found">

Related

How do I display and image from database to laravel blade?

I have followed the correctly marked answer in this question to save images in my app. I am having trouble displaying the images to blade file. I am using <img src="{{asset('/ProfileImages'.$p->profile_image)}}" alt="..."> ProfileImages is the storage folder with structure storage/app/ProfileImages. How do I display the images as the above line doesnot display?
Laravel storage filesystem is so unique. When you doing any upload it will upload in the storage/app/public directory. To make it accessible in public directory, things need to do is create symlink by run command:
php artisan storage:link
Or
<img src="{{ Storage::url($p->profile_image) }} " alt=""/>
StorageDocumentation
use Storage::url()
<img src="{{ Storage::url($p->profile_image) }}" alt="...">
ref link https://laravel.com/docs/8.x/filesystem#file-urls
By default when using {{asset()}} this will look inside your Public directory you should either consider storing photos inside your Public directory
Or take a look at the documentation about Laravel File System, here they explain how you can use storage directory and link it with your public directory
Laravel File System
Aslo you can use {{Storage::url()}} instead

Can't load images in laravel blade files

I've downloaded a template from here.
I want to design pages like that in laravel blade pages, I put css and js files in public folder and link blade files to them, and it works.
But I can't handle images, there isn't a folder for images in this template and I don't know how to load them in my blade pages.
you can upload images on below path
storage/app/public/images
//this way you can use in your blade file
<img src = "{{ asset('/images/YOUR_IMAGE.png') }}" />
but you need to run one command
php artisan storage:link
it will create a symlink from public/storage to storage/app/public
please insert as below path and make link like that.
try this.
<div class="hidden-xs" style="width:200px; height:auto; margin-left:-10px;">
<img src="{{ asset('uploads/logos/myLogo.png') }}">
</div>
If not working... then check your App Url in /.env and restart your app server.
APP_URL=http://localhost
Happy coding~!:)

dont get the right path in laravel for my uploads folder

i always use this to go to the public folder:
src="{{ asset('img/pic.png') }}">
everything works perfect
but now is it not possible because i want to show the avatar picture and
something like this not works
<img src="../../public/uploads/avatars/{{$user->avatar}}">
so ive used this but it doesnt work i dont know how to go to the uploads folder
does anybody know the reason?
thank you!!!
Within the asset() helper, you have missed out the uploads/ folder.
So this should be src="{{ asset('uploads/avatars/' . $user->avatar) }}"
If your uploads folder is in the public folder, there is no need to use the asset() helper. You could just use the following:
<img src="/uploads/avatars/{{$user->avatar}}">

not show image from public folder laravel

I created api for getting image from server and show user but when enter url in server shows (Sorry, the page you are looking for could not be found.)
notice: request work in localhost
Try below code :
<img alt="image name" src="{{ url('image/imagename.jpeg') }}" />
Try this to use public_path() function:
<img src="{{ public_path($IMAGE_PATH) }}">

Display images in Laravel

I can't get the images to display on my laravel website. I have the images in the public/img directory and have tried with
src="{{ url('img/logo.png' }}"
and
{{ HTML::image('img/logo.png') }}
I'm using Laravel 5.2. The url displays correctly in the web console as localhost:8000/img/logo.png but doesn't display the image
I don't know whether it was your typo when writing this post or not, can you try to change your code to:
src="{{ url('img/logo.png') }}"
^
you left out a close bracket
If there is any changes please leave it in comment, I will try to modify my answer.
Hope it helps =)

Resources