Return to Snippet

Revision: 32622
at September 30, 2010 19:00 by lgarcia


Initial Code
function get_image_src($posti = null) {
if (!$posti)
	global $post;
else
	$post->post_content = $posti;

$the_content = $post->post_content;
$pattern = '!<img.*?src="(.*?)"!';
preg_match_all($pattern, $the_content, $matches);
$image_src = $matches['1'][0];
return $image_src;
}

Initial URL

                                

Initial Description

                                

Initial Title
Extract first image from a post  (Wordpress)

Initial Tags
wordpress

Initial Language
PHP