I have this url codes to call my image in laravel storage
<img src="{{url('/storage/logo/') }}/{{ $logo }}" alt="abcd" width="50px" style="float: left; margin-right: 10px;">
but it didn't show up.
Can anyone help?
First issue you have you are passing two /'s in your image code (one after logo and out outside of the blade syntax).
More importantly, storage assets can't be shown on the front end by default
Firstly, you will need to run the php artisan storage:link artisan command to have the storage folder accessible. See here for more info.
Lastly, you can use the asset() helper to show files within the new symbolic folder. See here for more info
Then you should be able to do the following:
<img src="{{ asset('/storage/logo/ . $logo }}" alt="abcd" width="50px" style="float: left; margin-right: 10px;">
Related
I store an image with
$cat->picture = $request->file('catpicture')->store('public/catpictures');
$cat->save();
I do a ls in "/var/www/html/project/storage/app/public/catpictures", the image is saved
I created the symlink
php artisan storage:link
The [/var/www/html/project/public/storage] link has been connected to [/var/www/html/project/storage/app/public].
The links have been created.
In my blade I have:
<img src="{{url($cat->picture)}}" class="img-thumbnail" alt="Responsive image">
which is "public/catpictures/IgTx81OYKVymthuzTydFVepGvFZGALeeW1FmHpas.png"
The image doesnt show,what am I missing?
The src is http://127.0.0.1:8000/public/catpictures/IgTx81OYKVymthuzTydFVepGvFZGALeeW1FmHpas.png
Instead of using url, better to use asset to retrieve asset
Actually you don't need to add public prefix in your store() function. When you call store(), it will use the path from config/filesystems.php. The path will be taken from the default disks.
Asset vs Url
<img src="{{asset('/storage/' . $cat->picture)}}" class="img-thumbnail" alt="Responsive image">
I'm sending an email from my laravel application via Mailgun. I'm using the embed function so that the image's will showing Gmail as it blocks images but now im running into a problem with Apple Mail, if I set the image width and height it ignores this and shows the image at its true file size. So if I have an image with the width and height of 100px and set the width and height as 50px in my email Apple Mail ignores it but Gmail shows it as 50px as expected. Any work around for Apple Mail? Apple Mail shows it as the correct size when not using the embed feature in Laravel.
<img src="{{ $message->embed(public_path() . '/img/mail/logo.png') }}" width="22" height="22" style="max-width: 22px;-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;" />
Thanks in advance!
-Jamie
Change your code, do not use width and height attribute in tag. Use in style. I hope this will solve your problem.
<img src="{{ $message->embed(public_path() . '/img/mail/logo.png') }}" style="width:22px; height:22px; max-width: 22px;-ms-interpolation-mode: bicubic;vertical-align: middle;border: 0;line-height: 100%;height: auto;outline: none;text-decoration: none;" />
I am using laravel and trying to make it possible for users to change the background image of their page using an update form. They upload a pic and the pic is displayed using twig. My code below for getting the user image used for the background pic
$this['userprofile'] = User::with('background_pic')->where('id', $slug)->first();
The background pic is to be rendered in a div using the code below
<div align="center" style="height: 30px; background-image: url('{{ userprofile.avater.path }}');"></d>
the image uploads fine to the backend but not sure how to display it in twig. using the above background-image: url('{{ userprofile.avater.path}}') does not work
In order to render the background-image url from a variable you need to use the asset function.
This twig function resolves the path of your image to a publicly accessible URL.
Example usage:
<div style="background-image: url('{{ asset(userprofile.avater.path) }}');"></d>
I am trying to src an image into my html. Using Laravel as a backend.
<img class="card-img-top" src="storage/app/public/photos/{{$photo}}" alt="Card image cap">
I have also used the system link command and tried,
<img class="card-img-top" src="storage/{{$photo}}" alt="Card image cap">
In the past this would have been sufficent however, when using Laravel this does not link the image.
Does Laravel not allow direct 'src' links, or am I messing up the 'src' file structure?
Laravel uses blade syntax, variables ($) need to be between {{ }} in order to output their value.
So give <img class="card-img-top" src="storage/app/public/photos/{{ $photo }}" alt="Card image cap"> a try :)
i think the simple call like
<img src="storage/image/{{$data->photo}}" alt="">
$data = result from foreach
photo = column in db.
Correct file path is:
src="storage/photos/{{photo}}"
It skips /app/public
src="{{ url('assets/img') }}/{{ $item->photo }}"
Works for me!
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') }}">