I want to show picture form another folder. But why it's not working?
<img src="/picture/Capture.JPG" style="width:600px;height:400px">
My folder name is picture and image name is Capture.JPG
To print images ,css and js files correct path laravel have a default function asset()
Try this
<img src="{{ asset('picture/Capture.jpg') }}" style="height:400px;width:400px" >
I find my solution last night.
At first i create a folder in public folder name images. Then i store the picture. And the code formet is here.
<img src="{{url('/images/6.JPG')}}" alt="Image"/>
Related
This is for a small school assignment.
We are trying to create and deploy a search website of local cricket players.
I have everything running locally the only thing is I need to use is asset on my images to get them to deploy properly.
currently I have in my local
<img src="/images/{{$player['image']}}" class="playerimg">
I have tried concatenating it but to no avail.
The reason I have a variable $player is because we are pulling data from two tables and looping around the array.
Any help would be greatly appreciated
Edit: Solved Thank you all for your help ! code below
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
Laravel - Helpers: asset()
https://laravel.com/docs/master/helpers#method-asset
<img src="{{ asset('images/'.$player['image']) }}" class="playerimg">
There are several ways to display the image.
I'm assuming index.php in public folder.
asset() Generates a URL to an application asset (code)
Use for files that are directly served such as CSS, images, javascript.
Only accepts a direct path.
{{ asset('images/'.$player['image']) }}
// http://www.example.com/public/images/abc.png
If you stored your image in storage folder then,
<img src="{{ storage_path('images/'.$player['image']) }}">
Make sure config.php should be configured properly for storage_path.
Laravel image showing problem.I can't find where the problem happens
Image is not showing.I have tired using asset function
<!----------End Navbar Part----------------->
{{-- start Sidebar+Conent --}}
<img src="{{asset('images/products/p.png')}}" alt="This is a image">
I expect the image will be shown
Looking at the screenshot you added, it seems that you have a space in your filename.
The filename looks like "p .png". Check if there is a space and if so, remove it from your image filename.
I am trying to load images from the public folder in the vue components. The asset helper doesn't work in vue , so I need to use the format
<img :src="'img/ic_add-sm.svg'" >
But instead of looking for the images in the public folder , vue is appending the current URL to the image path. For example , if the url is www.example.com/posts
it adds www.example.com/posts/img/ic_add-sm.svg
instead of www.example.com/img/ic_add-sm.svg
Add a forward slash to the beginning of your image path.
<img :src="'/img/ic_add-sm.svg'">
Since you don't appear to be doing anything special you should be able to just use
<img src="/img/ic_add-sm.svg">
At first bind the value of image source
<img :src="getPhoto() + variableName" />
Then create the function under your methods section and simply return the directory location, that's all.
getPhoto(){
return 'images/';
}
Note that, You cant declare directory location directly to :src attribute.
I have a image that want show in slide show I use html tag <img src="">,
I'm new in laravel and I don't Know How to show image in my blade.
How I can use <img> tag in laravel?
<img src="{{ asset('/public/upload/image.jpg') }}">
If your image in public folder
If you have stored images inside laravel public directory then, you can use asset which refers to public/ directory.
If you have image at public/images/abc.png then, you can add image in view like this:
<img src="{{ asset('images/abc.png') }}">
I am trying to display images from a database through folder. I have a folder. Albums, and inside that more folders ("home", "school"). I'm saving images into "Album/home/a.jpg". I want to display images from folder ../home.. (eg: Album/home/a.jpg)
I used this code:
<a rel="prettyPhoto[pp_gallery]" class="thumbnail" href="{{URL::asset('/Albums/'.$gallery->galimg)}}" width="100%" height="100%" >
<img src="{{URL::asset('/Albums/'.$gallery->galimg)}}" width="100%" height="100%"/> </a>
but it's not working {{URL::asset('/Albums/'.$gallery->galimg)}} only see gallery place (one square) not image..
how to solve it??
I think you have to take care of few things.
Make sure that the folder Albums is located inside the public folder directly if not reference it.
Check the database whether you are storing just image name or full path or may be there is no extension of images on db.
No need to use URL facade. There is asset method which you can use directly ( specific in Laravel4.* ) like this {{ asset($gallery->image) }}