• Resolved erow80

    (@erow80)


    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

Viewing 6 replies - 1 through 6 (of 6 total)
  • 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.

    Thread Starter erow80

    (@erow80)

    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.

    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?

    Thread Starter erow80

    (@erow80)

    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.

    Thread Starter erow80

    (@erow80)

    Works great, thanks! Now for the jQuery….

    Hi,

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

    Cheers,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘custom page template: img src doesn’t function’ is closed to new replies.