Skip to content

Instantly share code, notes, and snippets.

@CarlLee
Created April 19, 2013 04:04
Show Gist options
  • Save CarlLee/5418071 to your computer and use it in GitHub Desktop.
Save CarlLee/5418071 to your computer and use it in GitHub Desktop.
a function to replace image URLs into <img>
function embed_images($content){
return preg_replace('/(https?\:\/\/[a-zA-Z0-9\-\.]+\.[a-zA-Z]{2,3}(?:\/\S*?)?(?:[a-zA-Z0-9_])+\.(?:jpg|jpeg|gif|png))/i', '<img src="$1"/>', $content);
}
add_filter(the_content', 'embed_images');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment