WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] custom page template: img src doesn't function (7 posts)

  1. erow80
    Member
    Posted 5 years ago #

    I've seen one other (unresolved) post that describes a similar problem I'm having but I wanted to go a little more in depth here. I've created a static homepage that will show a series rotating background images. When I set a background image in the css, it loads said image on the homepage. However, when I try to embed the file in the php as such:

    <img src="images/background1.jpg"/>

    I get nothing. To further complicate matters, I am planning on using jQuery for this task, specifically the plugin called Supersized. I created a page called "supersized.php" and loaded that independent of WP for testing, and it works flawlessly. However, I added the snippet:

    <?php include('supersized.php');?>

    into my custom template page and the CSS functions properly but none of the images load. I am just getting back into WP, and don't know much PHP, but I am rather comfortable with CSS and HTML. It seems to me there is conflict with WP and using <img src/> tags. Can anyone confirm or deny this?

    Also, I am testing locally so unfortunately I can't provide a link for viewing. I can provide additional code or try to explain my process better if needed.

    I am running WP 2.8.1 with the Corporate Sandbox theme.

    Thanks much,
    Eric

  2. EMG
    Forum Volunteer
    Posted 5 years ago #

    If you're embedding images into WP's template pages - either the default ones or any custom ones - you should stick with using either WP's custom php bits to write out the path (or use hard-coded paths, but that's usually not preferable) because otherwise the changing of permalink structures (changing to anything other than the default) interferes with how your relative paths are interpreted.

    How that might affect JQuery I'm not positive, but it's something to keep in mind.

  3. erow80
    Member
    Posted 5 years ago #

    Thanks for the input. Do you happen to have any resources, examples or any idea of what I can search for in the Codex to help figure this out? There may be a solution here, but I can't get it working:

    From that link, the post says that this bit of code worked for them:

    <img src="<?php bloginfo('stylesheet_directory'); ?>/images/hr.gif" alt="test">

    As for the jQuery, it's hard to say if that's working at all because no images are loading and that's the main function of this plugin.

  4. Mark / t31os
    Moderator
    Posted 5 years ago #

    I never used stylesheet directory, i always use (not that it should matter).
    <?php bloginfo('template_directory'); ?>/images/someimage.gif

    Such a path resolves to ..
    http://www.yoursite.com/wp-content/themes/YOURTHEME/images/someimage.gif

    If you open the page in IE, you should see a small box with a red cross. Right click and choose properties, does the path of the image match that of the actual image?

  5. erow80
    Member
    Posted 5 years ago #

    Thanks t, I'll look into that and post results here. I haven't had a chance to look into it just yet. I think it is starting to make sense.

  6. erow80
    Member
    Posted 5 years ago #

    Works great, thanks! Now for the jQuery....

  7. Ganymede100
    Member
    Posted 4 years ago #

    Hi,

    Am trying to get supersize 2.0 JQuery working with wordpress and wondered how you went.

    Cheers,

Topic Closed

This topic has been closed to new replies.

About this Topic