Add images into email template in Laravel - php

I´m trying to add img into Blade email in Laravel. But when I receive my email, I can´t see my image, but URL is correct. I´m trying to add img this way:
<img src="{{ asset('/public/images/guiapaladar-qrcode.png') }}" alt="" style="width: 20%;">
In Google Console I can see this:
<img src="https://ci5.googleusercontent.com/proxy/-Ay7pcevYLhUaAu4iicFdd-kGPKGB9hXRemwYYmoes8GnA4nN6Qe_FZDKenf_iDgiNpx5Xb1QX7p_2Su5DCOHAb2-UI8gGHkJhK9V6qb4R-B6_QY=s0-d-e1-ft#http://127.0.0.1/guiaPaladar/public/images/guiapaladar-qrcode.png" alt="" style="width:20%" class="CToWUd">
but in my email it doesn't show my image.
Thanks for help me

If you are sending email through localhost then image will not be displayed. But if you are sending it live then use the following code:
<img src="{{asset('images/guiapaladar-qrcode.png')}}" alt="" style="width: 20%;">

With using markdown you can just :
![Random text][logo]
[logo]: {{asset('/images/image.png')}} "Logo"
Or simply :
<img src="data:image/png;base64,{{base64_encode(file_get_contents(resource_path('images/image.png')))}}" alt="">

Related

Image not showing in .blade file

I'm new to Laravel, but why the hell is this not working?
<img src='../img/netflix_logo.png' />
I've tried using php artisan storage:link and it said The [C:\xampp\htdocs\laravel-crud\public\storage] link has been connected to [C:\xampp\htdocs\laravel-crud\storage\app/public]. The links have been created. but the image is still not displaying in my .blade page..
If you image is in storage/img then
<img src="{{ url('storage/img/netflix_logo.png') }}" alt="" title="" />
If you image is in public/img folder then
<img src="{{ URL::to('/') }}/img/netflix_logo.png" alt="" title="" />
You probably need to use the "asset" helper from laravel/blade:
asset('/path/of/your/image')
It's the common way to call a static file from public folder (including storage if you already linked it)

Image doesn't load - DATA-LAZY

I'm trying to load an image using bloginfo('template_directory')
My code:
<img class="img-fluid" style="max-height: 500px" src="<?php bloginfo('template_directory'); ?>/assets/home-image.png" />
The assets folder is inside my theme folder.
It works perfectly in my localhost.
But when I upload the code to my server I doesn't show the image.
When I inspect the element, here what it shows:
<img class="img-fluid" style="max-height: 500px" src="data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E" data-lazy-src="https://www.mywebsite.com/wp-content/themes/mytheme/assets/home-image.png">
Any guess?
Okay. I figured out that WP Rocket plugin was the problem. I had to disable the cache for imagens into the settings of that plugin.

change logo default notification email laravel 8

I´m traying chenge logo in notification email with laravel 8.
first i published all theme:
php artisan vendor:publish --tag=laravel-notifications
php artisan vendor:publish --tag=laravel-mail
and in header.blade into folder mail/html i´m doing this:
<img src="{{ asset('img/image_default.png') }}" class="logo" alt="Laravel Logo">
my image it´s in public/img
and i´m sending my email ok, but in gmail my logo img it´s broken. I´m using a vhost in localhost
in my email, img route it´s:
googleURLhttp://laravellimpio/img/image_default.png
i checked my asset in other blade and i can show my img ok. I don´t know if i have a problem with my code or it´s for used localhost.
Thanks for help me
Try this
<tr>
<td class="header">
<a href="{{ $url }}" style="display: inline-block;">
#if (trim($slot) === 'Laravel')
<img src="https://laravel.com/img/notification-logo.png" class="logo" alt="Laravel Logo">
#else
<img src="{{ asset('img/image_default.png') }}" class="logo" alt="My logo">
#endif
</a>
</td>
</tr>
As you can see there is a conditional statement checking if the app name is equal to Laravel, change the name of your app from the env file and then remove the {{ $slot }} and use your own path. You need to change the app name so that it skips the first portion of the statement and selects the space between the #else.

Image not show on web page (Laravel)

There is a route problem or image address problem. The image is not displaying on some pages but displaying on some pages:
This is the route address in which image is not displaying:
Route::get('users/edit/{id}', [App\Http\Controllers\UserController::class, 'edit'])->name('edit-user');
and this is the image address of this route:
http://localhost/Complain-Management-System/public/users/edit/images/1312455072.jpg
and this is the image source on blade:
<img src="images/{{ Auth::user()->image }}" class="rounded-circle" width="130" height="130" alt="">
The image is displaying good on this route:
Route::get('users', [App\Http\Controllers\UserController::class, 'index'])->name('manage-user');
and the image URL of this route is:
http://localhost/Complain-Management-System/public/images/1312455072.jpg
Can someone please solve this problem, it's important. Thanks
This was the src problem then i try to add the full address like:
<img src="/Complain-Management-System/public/images/{{ Auth::user()->image }}" class="rounded-circle" width="130" height="130" alt="">
and it works!

php email image not display in gmail

I want to display image in email that send from php. In yahoo the image was display but in gmail the image is missing.
This is the code for display image
<img alt="" data-pyroimage="true" src="{{ url:site }}image/sample.png" style="width:66%;" />
This is the image url after i inspect in gmail
<img alt="" src="https://ci5.googleusercontent.com/proxy/KaJG60d7WUoIwstJlDYAp8vLq1SSpmWyOZlrgZtUJMtHoBCEr863637_4tdJaibPlgJy7jnzXHs5RGv8C3g=s0-d-e1-ft#http://ipaddress/image/sample.png" style="width:66%" class="CToWUd">
I would suggest using the img plugin function to reveal a physical file location. If that's an image in the public directory something like this might work:
{{ img('public::image/sample.png').url }}
Then you can bet that Google will treat it much like a native image source.

Categories