I have the following function that I'm trying to use to get an image in the same directory as the plugin but inside the images folder.
function my_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo dirname(__FILE__); ?>/images/logo3.png);
height:65px;
width:320px;
background-size: 320px 65px;
background-repeat: no-repeat;
padding-bottom: 30px;
}
</style>
its is taken from the following, which works fine. yes "/" works.
function my_login_logo() { ?>
<style type="text/css">
#login h1 a, .login h1 a {
background-image: url(<?php echo get_stylesheet_directory_uri(); ?>/images/site-login-logo.png);
height:65px;
width:320px;
background-size: 320px 65px;
background-repeat: no-repeat;
padding-bottom: 30px;
}
</style>
What am I doing wrong?
'around the path?dirname(__FILE__)you get the absolute path from the server's file system root (e.g./var/www/html/images/logo3.png). To use it in CSS you need the relative path from the webserver's document root, which is a different path. For example, if the image is in/var/www/html/images/logo3.pngand the webserver's document root is/var/www/html, you need to use/images/logo3.pngin CSS.