Trouble with getting photos on website

I having troubles with photos on my website, here’s the code: <div class=“page-banner__bg-image” style=background-image: url(<?php echo "get_theme_file_uri(/images/library-hero.jpg);"; ?>); ?>);">

url(<?php echo "get_theme_file_uri(/images/library-hero.jpg);

am I doing anything wrong

1 Like

You should probably have quotes around the URL. Try this:

<?php echo "get_theme_file_uri('./images/library-hero.jpg');"; ?>

Starting your URL with ./ instead of / is important (or you can leave off the slash, but I like it). Linux recognizes / as the root directory, which, in the context of the PHP server, is likely the webroot in all cases, but if you happened to use Linux and you previewed a HTML file in your browser, the slash would be interpreted as looking for the root directory of your filesystem. That’s the worst-case scenario, and nothing bad is guaranteed to happen if you use /, but . is a universal symbol across all modern shells for “target the folder I am currently looking at” (compare with .., which represents the directory that contains the current directory). ./ is an explicit message about where to start looking for the file and using it not only ensures that your experience will be consistent regardless of how your file is served, but that a reader observing your code has one more piece of information about what you intended.

1 Like