Support » Themes and Templates » Image path for themes

  • I’m creating my first theme, however the paths within the theme don’t seem to be relative. For instance, if I reference an image file as ‘images/header.jpg’ it looks in the wordpress/images directory as opposed to wordpress/wp-content/themes/mytheme/images.

    Is there a place to designate the the location of the theme so it will automatically look there for relative paths?

Viewing 3 replies - 1 through 3 (of 3 total)
  • I am new at this as well, so take my advice with a grain of salt. But, in my tinkering with themes, I have experienced your same issue & have found that the following is a solution:

    replace something like:
    <img src=”images/header.jpg” width=”300″ height=”25″ alt=””>

    with this:
    <img src=”<?php bloginfo(‘stylesheet_directory’); ?>/images/header.jpg” width=”300″ height=”25″ alt=””>

    Thanks, that works and it looks like that is how it is done in the default template. So unless I figure something else out I will assume that is how it is supposed to work.

    I just whack all my images in my wp-images folder and call them using relative URL in my style.css

    (/wp-images/header.jpg)

    If I have lots and lots of themey images, I use folders, too.

    -wp-images
    –zoolander
    —image.jpg
    –mytheme
    —image.jp
    –howaboutthat
    —image.jpg

    (wp-images/zoolander/image.jpg)
    (wp-images/mytheme/image.jpg)
    (wp-images/howaboutthat/image.jpg)

    works for me.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Image path for themes’ is closed to new replies.