Forums

[resolved] page displaying image alt text instead of image? (8 posts)

  1. jelly5131
    Member
    Posted 2 years ago #

    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

  2. wp-rory
    Member
    Posted 2 years ago #

    Hi Justine,

    Could you paste in the code you are using here?

    Many thanks,

    Rory. :)

  3. Mark / t31os
    Moderator
    Posted 2 years ago #

    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..

  4. jelly5131
    Member
    Posted 2 years ago #

    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="http://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.

  5. nazcar
    Member
    Posted 2 years ago #

    images/ll_banner.gif

    not found.. upload it to your 'images' directory.

  6. Mark / t31os
    Moderator
    Posted 2 years ago #

    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..

  7. jelly5131
    Member
    Posted 2 years ago #

    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.

  8. Mark / t31os
    Moderator
    Posted 2 years ago #

    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... ;)

Topic Closed

This topic has been closed to new replies.

About this Topic