I have an img folder within the public folder of my Laravel 5.4 project. When I refer to the image with the following code.
<img class="mb-3 img-fluid rounded" src="public/img/pdx.jpg" alt="Portland">
I get the broken image icon on the page. I am using Bootstrap 4 cdn for the this page. What am I doing wrong. Any help would be appreciated.
Just remove public from src attribute and then try. Because Laravel only understand assets within public folder
Related
Can you please give me an example: I used seeder to create an image for the user, but I couldn't load it, even though I ran php artisan storage:link , and checked the path of the image (the url is correct. ). Please help me explain
The code I used in factory file to create an Image
'image' => $this->faker->image('storage/app/public/users', 140, 180, null, false),
The img tag I used to load an image :
<img src="{{ asset('storage/users/' . $user->image) }}" class="avatar avatar-sm me-3 border-radius-lg" alt="user1">
When I inspected the url of an image
This is my folder structer
I guess it's your laravel project diectory bring about this problem.
Asset helper extract your imagećjs from laravel default public folder.
Copy a image to default public folder and try it again :)
https://laravel.com/docs/9.x/helpers#method-asset
Did you run the storage:link artisan command?
php artisan storage:link
After that you could use your img tag
<img src="{{ asset('storage/users/' . $user->image) }}" class="avatar avatar-sm me-3 border-radius-lg" alt="user1">
I try to access an image that is in following location:
storage/app/public/uploads/myImageIsHere.jpeg
I have tried all stack overflow options, public_path, Storage::url, creating a symlink link and thousands others.
Can someone explain me how to access this image in my .blade file ??
<img src="{{ Storage::url("app/sponsors/8R4HnbOzDdUilnSaZSRj9VzmeI7oKI9JrCWe3rgY.jpeg") }}">
GET http://127.0.0.1:8000/storage/app/sponsors/8R4HnbOzDdUilnSaZSRj9VzmeI7oKI9JrCWe3rgY.jpeg 404 (Not Found)
And this returns a correct path according to my img src path.
Thanks a lot!
Did you try ,
Storage::get("app/public/uploads/myImageIsHere.jpeg");
https://laravel.com/docs/5.8/filesystem
use this instead
<img src="{{ URL::to("/images/abc.jpg") }}">
this will return an image namely abc.jpg inside "public/images" folder.
Run php artisan storage:link to create a symlink to your public storage disk. After that you can access your image like that:
<img src="{{ 'storage/uploads/8R4HnbOzDdUilnSaZSRj9VzmeI7oKI9JrCWe3rgY.jpeg' }}">
I am using Drupal 8 and i created a page where i display an image and a form inside a block as an inline template.
This looks like this :
<div class="col-md-6" style="padding-right:0px; padding-left:0px;">
<img src="{{ base_path ~ directory }}/sites/default/files/Dinard_S.jpg" id="b-frm-img" style="width: 400px; height:300px;"></div>
Then another div contains my form. What i'm trying to do is to make user with no code knowledge able to change this specific image from the drupal admin.
Is there any way to do this?
I created an admin page to upload an image in a dedicated folder using managed_file type in the form. Seems there is no better ways.
I am using Laravel, and I want to display an image. I have the public/img folder, and this is the code
<img src="{{ URL::asset("img/background1.jpg") }}" alt="Unsplashed background img 1">
The image does not appear. When I inspect the page however, it returns the correct link, http://localhost:8000/img/background1.jpg but it says 0x0 px.
Add a / in front as the public folder is the root...
<img src="{{ URL::asset("/img/background1.jpg") }}" alt="Unsplashed background img 1">
Are you getting correct image when you open this link in browser? If so, then it would be issue with img height-width. Try setting static height-width for img and check.
Hope this helps..
I am making a web page on laravel 5, I haven't used laravel since it was at 3 but I really like the new features that it has.
Everything its working fine on an app that it's almost finished, but I have a problem with images.
I am trying to display an image to a view and it's just not showing, I get the little image icon that we all know.
I have used all the methods that I have found on larval docks and in the forums.
including:
assets
URL
HTML (It didn0t work at all)
Direct Url in the view
I am actually using just Artsian serve so the URL would be something like:
http://localhost:8000/uploads/images/posts/1456814127.jpg
The folder its un public folder so in my opinion its the correct url.
With diffrent methos i aslo called the image from the pc path and its the same result. I am using intervention to upload the image by the way.
Any idea?
EDIT:
Ok i tried on localhost of wamp server and the image output worked. I dont know why but it did.
EDIT 2:
I am on laravel Homestead now, and it's still not working. I am angry by this point. Please help me!!
Here it's my Controller:
public function posts()
{
$posts = DB::table('posts')->paginate(3);
//page heading
$title = 'Latest Posts';
return view('frontend.posts.index')->with(compact('posts', 'title'));
}
This it's my view:
<a href="#" class="image">
<img src="{{ asset('uploads/images/posts/'.$post->post_image) }}" class="img-rounded">
<span class="hover-zoom"></span>
</a>
At laravel homestead the output link it's:
http://krubbit.dev/uploads/images/posts/1457074877.jpg
The dir structure of the image location:
-Laravel-dir
-Public
-Uploads
-images
-posts
-1457074877.jpg
Something like this
<img src="{{ asset('uploads/images/posts/1456814127.jpg') }}" />
Please use url funcion of Laravel as shown below
<a href="#" class="image">
<img src="{{url('asset/uploads/images/posts/'.$post->post_image)}}" class="img-rounded">
<span class="hover-zoom"></span>
</a>
Hope this will help..!!