php email image not display in gmail - php

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.

Related

Add images into email template in Laravel

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="">

How to display a pdf file in laravel blade view and undownloadable

i'm using Laravel for my application, i want to show a PDF file in view
i know i have to use <embed> or <iframe> but when i use this tags, i can't see my PDF file in my view and it will download automatic, i dont want to download file, just need to see PDF file content.
this is my view :
<div class="row justify-content-center">
<div id="detail_div_a4">
<embed src="{{ $letter->image }}" type="application/pdf" width="100%" height="600px">
</div>
</div>
src return my PDF file location in $letter->image
thank you for your helps <3
As you mentioned, you can use "iframe" to display your pdf. Here is a sample of code that should work for you.
<div class="row justify-content-center">
<iframe src="{{ asset('folder/file_name.pdf') }}" width="50%" height="600">
This browser does not support PDFs. Please download the PDF to view it: Download PDF
</iframe>
</div>
You can play around with the asset declaration to include your variable vs the file path. You can also test this code without your variable to see if that is causing the issue. You may also have some conflicting code in your custom div. Keep in mind you can style the pdf container in the iframe, so you may not need the div labeled "detail_div_a4". Good luck.
Here is another thread that may offer some additional support: HTML embedded PDF iframe

Embedding image in laravel markdown email

I'm trying to embed an image into my markdown email but it's not loading correctly.
https://i.imgur.com/lNCwhod.png
This is my mail template:
#component('mail::message')
# {{ $mailData['title'] }}
![{{ $mailData['appName'] }}]({{ asset($mailData['image'])}})
{!! $mailData['body'] !!}
Saludos,
{{ $mailData['appName'] }}
#endcomponent
This is the value of $mailData['image']:
'/img/misc/default.jpg'
Any idea how I can do this?
You can use html to add an image to your markdown:
#component('mail::message')
# {{ $mailData['title'] }}
<img src="{{asset('img/logo.png')}}" style="width:30%" alt="App Logo">
...
#endcomponent
Also you can use the style tag to customize the image.
Be aware if you are in localhost, you aren't going to see the image in the email (unless you are using mailhogh to test your emails).
As far as I know, the image has to be in your server hosted, so the image will not attached on the email.
Your server need an IP public or a domain to be able to see the images within the email.
You can try this markdown:
![Image_Alter_Text](PAHT_OF_IMAGE)
You have to pass complete path of image, and you get complete path by using Storage::url($file_name). Store image path in variable and pass in markdown.
For example :
![DemoImage](https://i.stack.imgur.com/bENi3.jpg)
Note: The image (logo of stackoverflow) is used in this comments is only for demo purpose.

Laravel - Image does not appear in view

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..

Image Upload through Javascript

I am getting image from clipboard and putting in img tag.
So when user click on a button, image from the clipboard is copied into img tag in one div tag. So I have list of img tags within one div.
I want to save that images on server, So I have to send that images to server side.
How can I send that images on server side ?
Please guide. Thanks.
=== Code Sample ===
<div id="imageContainer">
<img src="..."/>
<img src="..."/>
<img src="..."/>
</div>
this is the structure and want to upload this images on server.

Categories