Jetpack_Photon::parse_images_from_html PHP Méthode

    public static function parse_images_from_html($content)
    {
        $images = array();
        if (preg_match_all('#(?:<a[^>]+?href=["|\'](?P<link_url>[^\\s]+?)["|\'][^>]*?>\\s*)?(?P<img_tag><img[^>]*?\\s+?src=["|\'](?P<img_url>[^\\s]+?)["|\'].*?>){1}(?:\\s*</a>)?#is', $content, $images)) {
            foreach ($images as $key => $unused) {
                // Simplify the output as much as possible, mostly for confirming test results.
                if (is_numeric($key) && $key > 0) {
                    unset($images[$key]);
                }
            }
            return $images;
        }
        return array();
    }

Usage Example

 /**
  * @comment This test is horrible because it runs multiple tests inside this one method. - blobaugh
  * @author unknown
  * @pre-2.3.3
  */
 function test_parse_images_from_html()
 {
     $directory = __DIR__ . '/modules/photon/sample-content';
     $files = glob($directory . '/' . '*.html');
     foreach ($files as $file) {
         $file_contents = file_get_contents($file);
         list($sample_html, $expected) = explode("\n--RESULTS--\n", $file_contents, 2);
         $this->assertEquals($expected, print_r(Jetpack_Photon::parse_images_from_html($sample_html), true));
     }
 }
All Usage Examples Of Jetpack_Photon::parse_images_from_html