I use a function in my blog (getImage) to call thumbnails in the loop (it calls the 1st image on the post) but instead of link to the post, i would want the thumbnail to link to its full image src.
The function is this one:
function getImages($num) {
global $more;
$more = 1;
$link = get_permalink(); -> NO IDEA IF HAS ANY SENSE BUT I ALREADY TRIED TO CHANGE THIS ONE TO GET_ATTACHMENT BUT NO LUCK
$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]*)"/', '/width="150"/',$postOutput);
$postOutput = preg_replace('/alignright/', 'aligncenter',$postOutput);
$image[$i] = $postOutput;
}
if(stristr($image[$num],'<img')) { echo '<a href="'.$link.'">'.$image[$num]."</a>"; }
$more = 0;}
Does anyone has some clue how can i do this? or other function to achieve this?
Thanks
Simply use
wp_get_attachment_url($GLOBALS['post']->ID);
instead ofget_permalink();
Oh sure, so here is what i did:
I added this other function
And I call it at the $link line, in the getimages function.
Well is messy so i will try your suggestions and see if any of those will work, thanks a lot.