Created
August 1, 2012 02:59
-
-
Save JGallardo/3223222 to your computer and use it in GitHub Desktop.
WordPress- To remove links from images uploaded to posts. Add this code to functions.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment