• Resolved jelly5131

    (@jelly5131)


    I’m trying to place an image on my index.php file, but instead of displaying the image, it displays the text of whats in the alt tag (or nothing at all if I dont have an alt tag). I’ve tried the same tag on a site not within wordpress and it displays the image just fine. Can anyone help me with this?

    Thanks,
    Justine

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi Justine,

    Could you paste in the code you are using here?

    Many thanks,

    Rory. ??

    It’s the path, it’s not finding the image, hence why you see the alt text, that’s what it’s for… when the image can’t be found or if the person viewing them doesn’t have image support..

    View source, go to where the image should be and look at the src="" part. If you’re confident the path is correct, copy and paste the URL from the src into your address bar and see if you can view the image..

    Thread Starter jelly5131

    (@jelly5131)

    Ok, I’ve tried two different things. First, I have a folder called images within my theme, so the first path i tried was:
    <img src="images/ll_banner.gif" alt="banner">
    This prints the alt text.

    Then i tried the following:
    <img src="https://www.louisalanewoodlover.com/ll_banner.gif" alt="banner">
    This doesnt display the alt text, and if I look at the source code, instead of my image tag, it has empty html comment tags. I know this url is right, because I can browse to it.

    images/ll_banner.gif

    not found.. upload it to your ‘images’ directory.

    Ok well this really depends on where you’re tying to use this code..

    If you’re using it in a post and it’s in the theme folder you’ll need the theme path…
    <img src="wp-content/themes/YOURTHEME/images/yourimage.gif">

    If you’re coding it into your theme, then use..
    <img src="<?php bloginfo('template_directory'); ?>/images/yourimage.gif">

    NOTE:
    If you’re trying to use an image in the post, use the built-in media options for uploading and displaying images and it will create the correct path for you..

    Thread Starter jelly5131

    (@jelly5131)

    Thanks for the help, I got it working. I ended up using
    <img src="<?php get_bloginfo('url'); ?>/yourimage.gif">

    The picture was a banner to go on the index page.
    I tried the template_directory as suggested, which still didnt work. So i tried url instead, and that works fine.

    Well it really depends where you are targeting…

    If the image is in the root of the site, then the above will work…

    You initial post suggested that you were placing the image in the theme’s images folder…

    ??

    Glad you got it how you want it in any case… ??

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘page displaying image alt text instead of image?’ is closed to new replies.