Created
April 19, 2013 04:04
-
-
Save CarlLee/5418071 to your computer and use it in GitHub Desktop.
a function to replace image URLs into <img>
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
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