function get_media_item_v1_1($media_id)
 {
     $media_item = get_post($media_id);
     if (!$media_item || is_wp_error($media_item)) {
         return new WP_Error('unknown_media', 'Unknown Media', 404);
     }
     $file = basename(wp_get_attachment_url($media_item->ID));
     $file_info = pathinfo($file);
     $ext = $file_info['extension'];
     $response = array('ID' => $media_item->ID, 'URL' => wp_get_attachment_url($media_item->ID), 'guid' => $media_item->guid, 'date' => (string) $this->format_date($media_item->post_date_gmt, $media_item->post_date), 'post_ID' => $media_item->post_parent, 'file' => $file, 'mime_type' => $media_item->post_mime_type, 'extension' => $ext, 'title' => $media_item->post_title, 'caption' => $media_item->post_excerpt, 'description' => $media_item->post_content);
     if (in_array($ext, array('jpg', 'jpeg', 'png', 'gif'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         $response['height'] = $metadata['height'];
         $response['width'] = $metadata['width'];
         $response['exif'] = $metadata['image_meta'];
     }
     if (in_array($ext, array('mp3', 'm4a', 'wav', 'ogg'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         $response['exif'] = $metadata;
     }
     if (in_array($ext, array('ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         $response['height'] = $metadata['height'];
         $response['width'] = $metadata['width'];
         // add VideoPress info
         if (function_exists('video_get_info_by_blogpostid')) {
             $info = video_get_info_by_blogpostid($this->api->get_blog_id_for_output(), $media_id);
             $response['videopress_guid'] = $info->guid;
             $response['videopress_processing_done'] = true;
             if ('0000-00-00 00:00:00' == $info->finish_date_gmt) {
                 $response['videopress_processing_done'] = false;
             }
         }
     }
     $response['meta'] = (object) array('links' => (object) array('self' => (string) $this->get_media_link($this->api->get_blog_id_for_output(), $media_id), 'help' => (string) $this->get_media_link($this->api->get_blog_id_for_output(), $media_id, 'help'), 'site' => (string) $this->get_site_link($this->api->get_blog_id_for_output())));
     // add VideoPress link to the meta
     if (in_array($ext, array('ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v'))) {
         if (function_exists('video_get_info_by_blogpostid')) {
             $response['meta']->links->videopress = (string) $this->get_link('/videos/%s', $response['videopress_guid'], '');
         }
     }
     if ($media_item->post_parent > 0) {
         $response['meta']->links->parent = (string) $this->get_post_link($this->api->get_blog_id_for_output(), $media_item->post_parent);
     }
     return (object) $response;
 }
 private function get_media_item_v1_1($media_id)
 {
     $media_item = get_post($media_id);
     if (!$media_item || is_wp_error($media_item)) {
         return new WP_Error('unknown_media', 'Unknown Media', 404);
     }
     $file = basename(wp_get_attachment_url($media_item->ID));
     $file_info = pathinfo($file);
     $ext = $file_info['extension'];
     $response = array('ID' => $media_item->ID, 'URL' => wp_get_attachment_url($media_item->ID), 'guid' => $media_item->guid, 'date' => (string) WPCOM_JSON_API_Date::format_date($media_item->post_date_gmt, $media_item->post_date), 'post_ID' => $media_item->post_parent, 'author_ID' => (int) $media_item->post_author, 'file' => $file, 'mime_type' => $media_item->post_mime_type, 'extension' => $ext, 'title' => $media_item->post_title, 'caption' => $media_item->post_excerpt, 'description' => $media_item->post_content, 'alt' => get_post_meta($media_item->ID, '_wp_attachment_image_alt', true), 'thumbnails' => array());
     if (in_array($ext, array('jpg', 'jpeg', 'png', 'gif'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         if (isset($metadata['height'], $metadata['width'])) {
             $response['height'] = $metadata['height'];
             $response['width'] = $metadata['width'];
         }
         if (isset($metadata['sizes'])) {
             /**
              * Filter the thumbnail sizes available for each attachment ID.
              *
              * @module json-api
              *
              * @since 3.9.0
              *
              * @param array $metadata['sizes'] Array of thumbnail sizes available for a given attachment ID.
              * @param string $media_id Attachment ID.
              */
             $sizes = apply_filters('rest_api_thumbnail_sizes', $metadata['sizes'], $media_id);
             if (is_array($sizes)) {
                 foreach ($sizes as $size => $size_details) {
                     $response['thumbnails'][$size] = dirname($response['URL']) . '/' . $size_details['file'];
                 }
             }
         }
         if (isset($metadata['image_meta'])) {
             $response['exif'] = $metadata['image_meta'];
         }
     }
     if (in_array($ext, array('mp3', 'm4a', 'wav', 'ogg'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         $response['length'] = $metadata['length'];
         $response['exif'] = $metadata;
     }
     if (in_array($ext, array('ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v'))) {
         $metadata = wp_get_attachment_metadata($media_item->ID);
         if (isset($metadata['height'], $metadata['width'])) {
             $response['height'] = $metadata['height'];
             $response['width'] = $metadata['width'];
         }
         if (isset($metadata['length'])) {
             $response['length'] = $metadata['length'];
         }
         // add VideoPress info
         if (function_exists('video_get_info_by_blogpostid')) {
             $info = video_get_info_by_blogpostid($this->site->blog_id, $media_id);
             // Thumbnails
             if (function_exists('video_format_done') && function_exists('video_image_url_by_guid')) {
                 $response['thumbnails'] = array('fmt_hd' => '', 'fmt_dvd' => '', 'fmt_std' => '');
                 foreach ($response['thumbnails'] as $size => $thumbnail_url) {
                     if (video_format_done($info, $size)) {
                         $response['thumbnails'][$size] = video_image_url_by_guid($info->guid, $size);
                     } else {
                         unset($response['thumbnails'][$size]);
                     }
                 }
             }
             $response['videopress_guid'] = $info->guid;
             $response['videopress_processing_done'] = true;
             if ('0000-00-00 00:00:00' == $info->finish_date_gmt) {
                 $response['videopress_processing_done'] = false;
             }
         }
     }
     $response['thumbnails'] = (object) $response['thumbnails'];
     $response['meta'] = (object) array('links' => (object) array('self' => (string) $this->links->get_media_link($this->site->blog_id, $media_id), 'help' => (string) $this->links->get_media_link($this->site->blog_id, $media_id, 'help'), 'site' => (string) $this->links->get_site_link($this->site->blog_id)));
     // add VideoPress link to the meta
     if (in_array($ext, array('ogv', 'mp4', 'mov', 'wmv', 'avi', 'mpg', '3gp', '3g2', 'm4v'))) {
         if (function_exists('video_get_info_by_blogpostid')) {
             $response['meta']->links->videopress = (string) $this->links->get_link('/videos/%s', $response['videopress_guid'], '');
         }
     }
     if ($media_item->post_parent > 0) {
         $response['meta']->links->parent = (string) $this->links->get_post_link($this->site->blog_id, $media_item->post_parent);
     }
     return (object) $response;
 }