WordPress.org

Forums

[resolved] Relative URL doesn’t work. (4 posts)

  1. Jayjerome
    Member
    Posted 8 years ago #

    I’m calling an image into my sidebar (from sidebar.php) but have to use the full Absolute URL to make it appear.
    The relative URL address doesn’t seem to work.

    The loooooonnnnnnngggggg Absolute address is :
    ‘<img src="http://localhost/wordpress/wp-content/themes/MistyLook/img/todaysspin.png" alt="Today's Spin">’

    So far, I’ve tried all the following variations of the Relative HTML address, unsuccessfully:
    '<img src="img/todaysspin.png"'
    '<img src="/img/todaysspin.png"'
    '<img src="./img/todaysspin.png"'
    '<img src="../img/todaysspin.png"'
    '<img src="mistylook/img/todaysspin.png"'
    '<img src="/mistylook/img/todaysspin.png"'

    Am I missing a period or a comma or something?

  2. muelheim
    Member
    Posted 8 years ago #

    If your page is in http://localhost/wordpress/wp-content/themes/MistyLook/
    <img src="img/todaysspin.png"> should do it (did you forget the closing >)?

  3. Kafkaesqui

    Posted 8 years ago #

    The 'relative' address that might work is:

    <img src="wp-content/themes/MistyLook/img/todaysspin.png"

    The file path will be handled relative to the current directory one is at; and by that I don't mean the template file, but you and your web browser.

    One way to handle this in templates is to use the bloginfo() template tag like so:

    <img src="<?php bloginfo('template_dir'); ?>/img/todaysspin.png"

    This will produce an absolute url to the image, but dynamically (so you don't need to edit it whenever you move things, etc.).

  4. Jayjerome
    Member
    Posted 8 years ago #

    the '<img src="wp-content/.. etc"> worked...

    thanks for the help.

    jj

Topic Closed

This topic has been closed to new replies.

About this Topic