Is the images folder like this?
…/wp-content/uploads/images/ You need to work out where you uploaded images will be stored going forward. Such as date and year. Then there are WP functions to display the directory path.
Dear Bloke, Yes the images are in uploads directory of wp-content so path is: …/wp-content/uploads/images/. I’ve deselected “Organize my uploads into month- and year-based folders” in Settings > Media. Images used in earlier posts are in month and year based folders but going forward I would like it to access them from the …/wp-content/uploads/images/ folder.
Thanks for the link. I’m a rank newbie to WordPress and php so please indulge me and give me step by step guidance on how I would go about telling WordPress to access the images from …/wp-content/uploads/images/.
I don’t know if you are putting this directly in a post or page. Or are you putting it in a function? You can try this:
$upload_dir = wp_upload_dir();
echo '<img src="'. $upload_dir['basedir'] . '/images/xyz.gif" />';
or this:
echo '<img src="'. site_url() . '/wp-content/uploads/images/xyz.gif" />';
Perhaps I did not make myself clear. I have a static html site where images are stored in an images folder. For instance in an article about Namibia the image is referenced in the site as following:
<img src=”images/namibia_map.gif”>
When I copy content from html site to WordPress I want to reference this same image as either <img src=”wp-content/uploads/images/namibia_map.gif”> or <img src=”images/namibia_map.gif”>. I don’t want to type this php code in every post I make but showing wordpress where images folder is located so it can automatically reference it.
When I’m moving a static html site to Joomla. I store images in images folder and then reference them article by article by typing in html in Joomla and it will find it. This is useful when moving html code of an exisitng site. If a post has 25 images, it is a big hassle to import images one at a time. I just copy the html code and images show up in Joomla. i would like similar functionality in Wordrpress.
This should work if you want to do it this way.
<img src='/wordpress/wp-content/uploads/images/xyz.gif' />
It depends on if you have wordpress in its on folder. But You should move away from HTML content so everything can be more flexible with dynamic links using PHP. If your URL changes you change one file and everything doesn’t break.
Thanks for the effort but sorry does not work. I pointed it to the folder where WordPress is installed but it does not display the image.
Your point about dynamic links is well taken. This is only for pre-existing content that is hundreds of pages with thousands of images to importing images in these pages is a lot of unnecessary work.