Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BruceM's avatar

Image in a blade

I store images in the directory projectname/storage/app/public/images. In regular blade files they are referred to in this way:

<a class="navbar-brand" href="{{ url('/home') }}">
                    <img src="/storage/images/Portal.jpg" class="img-fluid float-left" width="50" height="50">
                    Threshold - <small><small>QB as of {{session('qbupdate')}}</small></small>
                </a>

I recently installed DOMpdf and noticed that the image file for the pdf blade was not found unless it was referred to in this way (no slash before storage):

<img src="storage/images/ch.png" class="img-fluid float-left" width="300">

Then I tried to place the image in the body of an email blade and neither of the previous methods worked. The only thing that worked was:

<img src="{{asset('storage/images/ch.png')}}" class="img-fluid float-left" width="300">

This kind of inconsistency can drive a developer up the wall . . .

0 likes
3 replies
jlrdw's avatar

Using helpers is optional. You can just do it the normal way if you wish like in PHP.

Snapey's avatar
Snapey
Best Answer
Level 122

You could use the asset helper everywhere?

Make sure your APP_URL is correct as this will be used if you create the pdf outside of a request cycle (eg in a queued job or scheduler)

BruceM's avatar

Thanks @snapey for a solid answer with a good tip. I will go with asset in the future, assuming it works consistently.

Please or to participate in this conversation.