multiple options.
my prefered one. dont include the image in your text. as its not supposed to be in the text. and get it over custom field.
how to: (easy setup)
Need to have:
1. create a custom field in your content.
>> field ‘image’
>> value ‘image_name’
2. disable the image organization by time in your media settings.
CODE:
$post_id = get_the_ID();
$image = get_post_custom_values(‘image’, $post_id);
$path = glob(‘wp-content/uploads/’.$image[0].’.*’);
if (is_file($path[0])) { echo ‘<img src=/’.$path[0].’ />’; }
1. get id of content
2. get custom value image_name from content
3. search the upload folder for image_name.* and set path
4. if is file echo the image
it is also possible to do it with organizing by time enabled but it will need much more coding. as you have to to check through some IF statements, and glob statements….
1. is your image always uploaded at the same date as the content?
2. do you have some “standard” images that you use for certain content, and have some images that you want to upload with some other contents? cuz than the content date and image date folder will not match all the time. means you have to write except rules for certain situations
3. is it ok to include e.g. 2011/09/image_name in your custom field, or you want it to be so flexible that just image_name will work
…..
further:
1. if you want to have links to it. just create a custom field for links. and wrap the link around the image
2. if you have more than 1 image, just use a for $i loop