Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I'm working to take a single page "site" built in jquery/css and convert it to a D6 module.

the code contains more than one css file which has classes like this:

background: url('images/stadium.jpg') no-repeat left top;

The question I have is: How do I get those images recognized?

Normally, in the tpl.php files I include with my module I set up my image like this and everything is fine:

<img src="print base_path().drupal_get_path('module','my_module'); /images/my_image.png" />

I don't know how to get images call from css classes to appear, and I can't build the path out all the way manually since I don't know where, or in what theme my module may end up.

If anyone has any ideas, or docs they can point me to I'd appreciate it. if you need any clarification please let me know.

Thanks! Steph

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Basically given:

background: url('images/stadium.jpg') no-repeat left top;

The image will be loaded from the path relative to the CSS file.

e.g:

/styles.css
/images/stadium.jpg

The image is loaded from the relative 'images' subfolder.

Presumably, if the design is all controlled by a module, you could drupal_add_css the css file and have the image files relative to that in the module folder.

share|improve this answer
    
In my module I am using drupal_add_css to include my css files, and thats working fine, but the relative images in those css files are not showing. I'm not sure how I'd use drupal_add_css to include those images as well, can you elaborate? thanks for answering! –  Stephanie Jan 14 '13 at 22:01
    
you'll need a folder 'images' in your module dir for those css images, it needs to be relative to the stylesheet path in the html source –  David Thomas Jan 14 '13 at 22:19
    
thats got it, I had the images dir but my path wasn't right. thank you so much for the help! –  Stephanie Jan 15 '13 at 16:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.