Handling image paths

I’m new in using sage and I’m using 8.5.1…

In my local, in my base.php, I use this <img src="../../app/themes/dev-site/dist/images/sample.png"> but when I’ve uploaded in on my server, images stopped working.

I searched other topics and they were using it like this<img src="<?= Assets\asset_path('images/sample.png ') ?>" alt="<?= get_bloginfo("name"); ?>"/>

Tried but the theme stopped working and didn’t show up anything…

As a new user, how do I properly handle images? do I have to change the paths before I use gulp --production and upload it to the web server?

Thank you!

Do this:

<img src="<?= get_template_directory_uri(); ?>/dist/images/sample.png">

In your CSS, you’d just use ../images/sample.png to reference it

1 Like

That did it! Thank you, @ben! :smiley: