Chris
Chris

Reputation: 2181

Laravel display image in email

I am sending an email to my users of something they've submitted to confirm. The users can upload images so I want to display these images in the email overview.

The images are being saved and I save the path in my database. Only when I try to display the images I get src=(unknown) when I spectate in my email client.

This is how I print out the images:

<img class="thumbnail" src="<?php echo '/storage/' . $filename ?>" />

$filename is passed as data from my mailable class when I just echo the $filename it is the right data from my database so there is no issue there.

Upvotes: 0

Views: 2240

Answers (2)

Chris
Chris

Reputation: 2181

Thanks to @codeit repsonse I fixed it this way:

<img class="mini-thumbnail thumbnail" src="<?php echo url('/storage/' . $filename); ?>" />

Upvotes: 2

Amrinder Singh
Amrinder Singh

Reputation: 5502

In email you can not simply show the image from storage folder until you give the absolute url of your website.

i.e. it should be like this:

<img class="thumbnail" src="<?php $SITE_URL.'/storage/' . $filename ?>" />

where $SITE_URL should have the absolute path of your website like: www.google.com/

That's it.

Upvotes: 0

Related Questions