WordPress.org

Ready to get started?Download WordPress

Forums

P2
Automatic Image Embed (3 posts)

  1. davidhinojosa
    Member
    Posted 2 years ago #

    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/

  2. davidhinojosa
    Member
    Posted 2 years ago #

    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.

  3. Lance Willett
    Theme Wrangler
    Posted 2 years ago #

    Hi David,
    WordPress does allow image URL embeds from Flickr, Photobucket, and SmugMug. See the full list here: http://codex.wordpress.org/Embeds.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic

Tags