• Resolved keithiopian

    (@keithiopian)


    I created a wordpress site and I stored all of my images in an images folder within the root wordpress folder. Whilst the website was local on my computer, I merely used ‘/images/image-name.png’ and everything would always lead to this folder. I have since uploaded the website to my server. Now my image paths are not working the same as they did locally. For my homepage (which was set to homepage in the settings tab), I just had to remove the first ‘/’ leaving the path ‘images/image-name.png’ however this does not work for other pages. For instance, header.php works just fine in the homepage, but the images do not display in alternate pages, yet they all just use the <? php get_footer(); ?> tag. If header.php works just fine on the homepage, why wouldn’t it work just fine in subsequent pages? Everything worked just fine locally, I am confused. Does anyone have any insight into this situation? Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • Thread Starter keithiopian

    (@keithiopian)

    Just updating my research here…

    So far, I have been able to ascertain that if it is an image used as part of the content window for a page and probably a post, then the image comes from the images folder in the root wordpress folder (ie. ../images/image-name.png). If the image is coming from a stylesheet used as a background image, then it uses the image folder within the theme folder (ie. images/image-name.png). What I can not figure out is when you use an image in a php file, for example, my logo in the header.php file. I used <img src=”images/logo.png” /> (this location is in the first level of wordpress folder, i.e. wordpress/images/logo.png) which works fine when my homepage goes out and looks for header.php, but when I have any other page go out and look for header.php, the image does not display.

    header.php is called from index.php most likely and your other post-pages are using archive.php or page.php or category.php etc..review with theme design…

    Thread Starter keithiopian

    (@keithiopian)

    Thanks for the reply, my header.php is being called by my index.php, but it is also being called by my page.php (or my derivatives thereof). All my pages start out calling header.php. My issue is that the images placed in my header.php, (e.g. <div><img src=”images/image.png” /></div>) only work on my front page, not on any other pages. All I have are pages thus far, I haven’t any blog pages, archives, catagories, etc. just a few core pages of my website thus far. All are created in the pages panel, all call the same header, but the one that is set to front page in “Settings>Reading>Front-Page” is the only one that accepts the image file path in the header.php… Does that make sense?

    Are you placing such after the first body tag?

    Thread Starter keithiopian

    (@keithiopian)

    Yes, just after

    <body <?php body_class(); ?>>

    live site link?

    Thread Starter keithiopian

    (@keithiopian)

    I guess theoretically, I am not even using index.php since I am diverting to a static page as my front page. I am only using page.php

    Thread Starter keithiopian

    (@keithiopian)

    I did a work around to get the logo in the top left corner to work, but if you look in the top right corner, that “e” is an image that only works on the home page

    Thread Starter keithiopian

    (@keithiopian)

    Oh yeah… this is a work in progress, so the only other link that works is the one in the bottom right labeled “ePub tour,” it will take you to a partially completed page that shows how the “e” disappears

    I usually put all images in the theme images folder. Then, whenever I call an image, I use:

    <?php bloginfo( stylesheet_directory ); ?>/images/imagename.jpg

    Other solutions include setting a variable like this:

    $imageurl = ‘https://www.mysite.com/images/&#8217;;

    Then you can just make image sources like this:

    <?php echo $imageurl ?>imagename.png

    Thread Starter keithiopian

    (@keithiopian)

    My friend… that is exactly the answer I am looking for. I knew there had to be a way to call on a centrally located image folder, but had no luck finding the answer. After hours of testing, I merely found that the pages are calling from the wp-content level and the background images in the stylesheets are being called from the theme level. This is exactly what I needed. Thanks!

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘image paths – local vs live’ is closed to new replies.