/i', $post_content, $matches); $first_img = $matches [1][0]; return $first_img; } function convertToFullUrl($src){ if(strpos($src, "http", 0) != 0 || strpos($src, "/", 0) == 0) { return get_bloginfo('wpurl').$src; } return $src; } function androapp_get_all_images($post_content){ if(PHP_VERSION_ID > 50207){ return androapp_get_all_images_using_dom_parser($post_content); }else{ return androapp_get_all_images_using_regex($post_content); } } function androapp_get_all_images_using_regex($post_content){ preg_match_all('//i', $post_content, $matches); $arr = $matches[1]; $images = array(); foreach ($arr as $im){ $image = array(); $image['src'] = $im; $image['width'] = 100; $images[] = $image; } return $images; } function androapp_get_all_images_using_dom_parser($post_content){ require_once 'simple_html_dom.php'; $html = str_get_html($post_content); $images = array(); foreach($html->find('img') as $element) { $image = array(); $image['src'] = $element->src ; $image['height'] = 200; $images[] = $image; } return $images; } ?>