Truncate additional tags from an image URL
<p>I want image urls to be auto embedded when post in post/comment field in a wordpress theme.</p>

<p>I already got this code to work in functions.php:</p>

<pre><code>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&lt;$m;$j++) {
$content=str_replace($links[$j],'&lt;img src="'.$links[$j].'"&gt;',$content);
}
}
return $content;
}
add_filter('the_content','content_magic');
</code></pre>

<p>BUT: as soon as you post via wordpress iphone app it doesn't work anymore because image posts from the iphone app automatically add the tags <strong>alt="20121108-172156.jpg" class="alignnone size-full" /></strong> at the end after"

<p>how can I truncate the "alt" and "class" tags after the end of the url starting from ?:jpe?g|png|gif" to "/> with the code above?</p>
