ajthinking
ajthinking

Reputation: 4558

img src root relative path not working

I have two routes mapped to the same html, generated with php blade template engine in laravel.

<img src="/images/logotype.svg" alt="">

The routes are

mydomain.com
mydomain.com/subscribers/1/edit

The first route works fine, finding the image at mydomain.com/images/logotype.svg

But the second route gives a broken image with image url like: mydomain.com/subscribers/1/edit/images/logotype.svg

From what I have read I have the right syntax for root relative paths in the html. What other error sources can I look for?


The html also includes js and css files. In that case it works fine for all routes like this:

<link rel="stylesheet" href="/css/app.css">

Upvotes: 1

Views: 3004

Answers (2)

Misagh Laghaei
Misagh Laghaei

Reputation: 1369

You should use asset() helper for generating full url of assets:

<img src="{{ asset('/images/logotype.svg') }}" alt="">

This will find the image from public/images/logotype.svg folder.

Upvotes: 1

Punith
Punith

Reputation: 191

If you want to add svg

<object type="image/svg+xml" data="/images/logotype.svg"></object>

Upvotes: 0

Related Questions