Hi there,
I am building a blog at the moment i have a amazing script that search a post for the images in it. So i can just setup a post template, call the images that are in the post and go. In this way i put the images unedited and unresized in the post and the template will make everything nice and smooth.:)
The thing is that the function works great, it produces a nice image with the image tags. Only the thing is:
I don't want the whole image wrapped up in a image tag,
i want only the src of it, i mean the url of the image.
I searched a lot but couldn't find a solution so thats why this posts excists.
Here is the function.
function getImage($num) {
global $more;
$more = 1;
$link = get_permalink();
$content = get_the_content();
$count = substr_count($content, '<img');
$start = 0;
for($i=1;$i<=$count;$i++) {
$imgBeg = strpos($content, '<img', $start);
$post = substr($content, $imgBeg);
$imgEnd = strpos($post, '>');
$postOutput = substr($post, 0, $imgEnd+1);
$postOutput = preg_replace('/width="([0-9]*)" height="([0-9]*)"/', '',$postOutput);;
$image[$i] = $postOutput;
$start=$imgEnd+1;
}
if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
$more = 0;
}
I just call the images with
<?php getImageUrl('1'); ?>
or
<?php getImageUrl('2'); ?>
etc
This will produce a in my case
<img class="a" title="htc-pure-1" src="http://www.site.com/wp-content/uploads/2010/03/htc-pure-1.jpg" alt="">
What i want is just
http://www.site.com/wp-content/uploads/2010/03/htc-pure-1.jpg
Onybody got a clue?