Skip to content

Instantly share code, notes, and snippets.

@lanche86
Created August 12, 2013 19:24
Show Gist options
  • Save lanche86/6214217 to your computer and use it in GitHub Desktop.
Save lanche86/6214217 to your computer and use it in GitHub Desktop.
Automatically Remove Links from WordPress Images
// Automatically Remove Links from WordPress Images
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