Solution:
add_filter( 'the_content', 'attachment_image_link_remove_filter' );
function attachment_image_link_remove_filter( $content ) {
$content =preg_replace(array('{<a(.*?)(wp-att|wp-content\/uploads)[^>]*><img}','{ wp-image-[0-9]*" /></a>}'),array('<img', '" />'), $content);
return $content;
}
/*place this code in your functions.php*/
/*if you wanna remove anchor tags which has image links, follow below code*/
add_filter( 'the_content', 'attachment_image_link_remove_filter' );
function attachment_image_link_remove_filter( $content ) {
global $post;
$exceptional_cjtypes = array("Mashup");
$cjtype = wp_get_post_terms($post->ID, "cjtype");
if(!in_array(strtolower($cjtype[0]->name), array_map('strtolower', $exceptional_cjtypes))) {
$content =preg_replace(
array('{<a href="(.*?(gif|jpeg|jpg|png))"><img}',
'{ wp-image-[0-9]*" /></a>}'),
array('<img', '" />'),
$content
);
}
return $content;
}