Hey Guys,

Working on converting a theme to Drupal. In the CSS file, it references images, and the image directory is in the theme directory... but it can't seem to find it? What's the path?

mytheme/images/* <-- where my images are
url(images/blah.jpg); <-- css, can't seem to find it?

I've also tried: /images/blah.jpg, and ./images/blah.jpg

And I've set the permissions on the server to match those as in the Zen theme.

Also used the Firefox Web Developer Extension to find the broken images, and it's all of them. Clicking on any of the links brings up a standard Drupal Page Not Found error.

The links according to the extension look like this:

http://www.mywebsite.com/themes/images/blah.jpg

This is driving me nuts! Any know the obvious thing I've probably overlooked :).

Thanks!
-gary

Comments

Chill35’s picture

mytheme/images/* <-- where my images are
url(images/blah.jpg); <-- css, can't seem to find it?

That's exactly what you should use : a relative path, relative to your stylesheet.

Is your style.css file really in the 'mytheme' folder, though ?

Caroline
Who am I | Where are we
11 heavens

andrenoronha’s picture

I got the same problem...
but my css files can't seem to change the images urls when I edit them...
I can edit anything on them... but the urls seem to be static!!

i'm going crazy!

========
André Luiz

andrenoronha’s picture

I found the answear myself...

the thing is: drupal was adding by itself the path: /drupal/sites/all/css before my path to the image...
so I put my own /drupal/sites/all/themes/themename/images/* and it worked either with abled as disabled css optimization...

========
André Luiz

davemybes’s picture

Usually, I use url(images/filename.jpg) with no problems. The images are in the "images" folder which is in the theme folder. Hence the path to an image will be: http://mysite.com/themes/themename/images/filename.jpg

The link you show above indicates that its not seeing your theme's folder. Have you tried adding the themename folder in the url() declaration? i.e. url(themename/images/filename.jpg). Normally you shouldn't have to, but in this case it looks like you need to.

______________________________________________________________________________________________________
Need help? Check the FAQ and the Handbooks first.

______________________________________________________________________________________________________

hapworth’s picture

It seemed to have worked out. I'm not exactly sure what I did (and yes, I had cleared the cache before). But images/blah.jpg eventually got picked up. Yay for sanity! :).

tdog’s picture

I'm having the same issue. Seems crazy to have to sit and wait for the magic to happen. I've tried different browsers so I'm sure it's not cache related.

tdog’s picture

the image I uploaded to my images directory did not have the correct permissions to be read by the world. All fixed now.

mani_kandan’s picture

You can change your permission for the file in your server depending.
In your server you can set the permission read or write or execute for the admin/client side.
And simply you can run the cron Administration menu-> Run cron.

And you can check the permission for the content for the users.

Hope these any ways will help you.

Thanks
- - -
Mani

rishi.kulshreshtha’s picture

Try this

url("../images/your_image.png") no-repeat scroll 0 0 transparent

Where ../images is a directory inside your theme folder.

Cheers!!!

indigetal’s picture

I've been trying to work out this very same issue all day today and I still don't know what's going on. I know the path to my image is /sites/default/files/myButton.jpg (uploaded to that location via the media module) and I've tried every variation of this as well as using the full url, trying it with/without parentheses, and nearly every suggestion here. I've even created an images folder in my theme folder and tried it that way but I got nothing. The only thing that I'm not clear on here is the permissions or public access to the images but the files folder is set as my public folder and I saw nothing to check or uncheck in the people/permissions area. Any other suggestions?

background-image: url(/sites/default/files/myButton.jpg) no-repeat right;

ohiageorge’s picture

assuming your images folder is within your theme folder like this : your_theme_folder/images

background-image: url(../images/myButton.jpg);

indigetal’s picture

That was it and I nearly had it myself before writing too. Thanks!

wzislam’s picture

The best soluton. Thanks.

../images/

CsarGabriel’s picture

background-image:[space]url[space](../images/logo.png);

jaypan’s picture

Those spaces are not necessary (I don't use them myself).

Contact me to contract me for D7 -> D10/11 migrations.