1

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

1 Answer 1

0

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.

3
  • 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!
    – StephanieF
    Commented Jan 14, 2013 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 Commented Jan 14, 2013 at 22:19
  • thats got it, I had the images dir but my path wasn't right. thank you so much for the help!
    – StephanieF
    Commented Jan 15, 2013 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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