For some reason I can not find any good solution to making the post images link to the post.
I found a script on http://wpguy.com/plugins/linked-image/ which works - but does not remove the old link, instead it wraps the old link and the image in a new a tag.
What I want is for the old link to be removed so the image is only wrapped in one a tag.
This is the script I currently have:
function wpguy_linked_image($content){
$searchfor = '/(<img[^>]*\/>)/';
$replacewith = '<a href="'.get_permalink().'">$1</a>';
if (is_single() === FALSE){
$content = preg_replace($searchfor, $replacewith, $content, 1);
}
return $content;
}
add_filter('the_content', 'wpguy_linked_image');
Does anyone have an idea?