Support » Theme: P2 » Auto embed image urls in posts/comments

  • I got this to work with this code in functions.php:

    //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) {
    for ($j=0;$j<$m;$j++) {
    $content=str_replace($links[$j],'<img src=”‘.$links[$j].'”>’,$content);

    return $content;

    BUT: as soon as you post via wordpress iphone app – it doesn’t work anymore because image posts from the iphone app end with “<img src=”http://image.jpg” alt=”20121108-172156.jpg” class=”alignnone size-full” />

    how can I cut off from .jpg” to “/> ?

  • The topic ‘Auto embed image urls in posts/comments’ is closed to new replies.