Title: [Theme: P2] Automatic Image Embed
Last modified: August 20, 2016

---

# [Theme: P2] Automatic Image Embed

 *  [davidhinojosa](https://wordpress.org/support/users/davidhinojosa/)
 * (@davidhinojosa)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/theme-p2-automatic-image-embed/)
 * Hello, I love how videos are automatically embedded when I input the video URL.
 * I would like some help doing the same thing with image URLs with an extension
   of JPG, JPEG, PNG, GIJ, and TIFF.
 * I have searched the plugin library and I have not yet found a solution.
 * I attempted to create an add_filter function with str_replace and regex but I
   was not able to code it properly.
 * Could someone help me with what I need done?
 * [http://wordpress.org/extend/themes/p2/](http://wordpress.org/extend/themes/p2/)

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [davidhinojosa](https://wordpress.org/support/users/davidhinojosa/)
 * (@davidhinojosa)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/theme-p2-automatic-image-embed/#post-2307891)
 * Here is the code I used.
 *     ```
       //function content_magic($content) { 
   
       //
       //$content = get_the_content();
       //
       //$m= preg_match_all('!http://[a-z0-9\-\.\/]+\.(?:jpe?g|png|gif)!Ui' , $content , $matches);
       //
       //
       //if ($m) {
       //    $links=$matches[0];
       //    for ($j=0;$j<$m;$j++) {
       //        $content=str_replace($links[$j],'<img src="'.$links[$j].'">',$content);
       //     }
       //}
       //
       //
       //
       //        return $content;
       //    }
       ```
   
 * This worked on another theme, but then my Video URLs would not automatically 
   be turned into videos.
 *  [Lance Willett](https://wordpress.org/support/users/lancewillett/)
 * (@lancewillett)
 * [14 years, 8 months ago](https://wordpress.org/support/topic/theme-p2-automatic-image-embed/#post-2308020)
 * Hi David,
    WordPress does allow image URL embeds from Flickr, Photobucket, and
   SmugMug. See the full list here: [http://codex.wordpress.org/Embeds](http://codex.wordpress.org/Embeds).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Theme: P2] Automatic Image Embed’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/p2/1.5.8/screenshot.png)
 * P2
 * [Support Threads](https://wordpress.org/support/theme/p2/)
 * [Active Topics](https://wordpress.org/support/theme/p2/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/p2/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/p2/reviews/)

 * 2 replies
 * 2 participants
 * Last reply from: [Lance Willett](https://wordpress.org/support/users/lancewillett/)
 * Last activity: [14 years, 8 months ago](https://wordpress.org/support/topic/theme-p2-automatic-image-embed/#post-2308020)
 * Status: not resolved