static function from_html($html_or_id)
{
$images = array();
if (is_numeric($html_or_id)) {
$post = get_post($html_or_id);
if (empty($post) || !empty($post->post_password)) {
return $images;
}
$html = $post->post_content;
// DO NOT apply the_content filters here, it will cause loops
} else {
$html = $html_or_id;
}
if (!$html) {
return $images;
}
preg_match_all('!<img.*src=[\'"]([^"]+)[\'"].*/?>!iUs', $html, $matches);
if (!empty($matches[1])) {
foreach ($matches[1] as $match) {
if (stristr($match, '/smilies/')) {
continue;
}
$images[] = array('type' => 'image', 'from' => 'html', 'src' => html_entity_decode($match), 'href' => '');
}
}
return $images;
}