• Hi All,

    I’m trying to insert an image from my images folder into a custom templates php file. For some reason, if I use a relative link to my images folder, it doesn’t work:
    <img src=”images/banner_temp.jpg” />

    But if I use an absolute link to my image, it works:
    <img src=”http://www.fake.com/images/banner_temp.jpg&#8221; />

    Does anyone know how to make an relative uri work in a templates file?

    Thanks in advance… D.T.

Viewing 4 replies - 1 through 4 (of 4 total)
  • <img src="<?php bloginfo('url');?>/images/banner_temp.jpg" />

    Thread Starter dackery_trane

    (@dackery_trane)

    Hi esmi,

    I tried what you suggested but it didn’t work. (Maybe it’s because I’m running wordpress locally offline.)

    I changed it to this…
    <img src=”<?php bloginfo(‘url’);?>/wp-content/themes/theme-name/images/banner_temp.jpg” />

    …and it worked.

    Thanks esmi for pointing me in the right direction!

    D.T.

    If the image is within your theme’s folders, use:

    <img src="<?php bloginfo('template_directory'); ?>/images/banner_temp.jpg" />

    Thread Starter dackery_trane

    (@dackery_trane)

    Yep, that worked perfectly! Thanks again!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Adding img tag into a template with a relative link’ is closed to new replies.