| @@ 171-185 (lines=15) @@ | ||
| 168 | * @param {Object} $media_item - media post object |
|
| 169 | * @return {Object} the snapshot object |
|
| 170 | */ |
|
| 171 | private function get_snapshot( $media_item ) { |
|
| 172 | $current_file = get_attached_file( $media_item->ID ); |
|
| 173 | $file_paths = pathinfo( $current_file ); |
|
| 174 | ||
| 175 | $snapshot = array( |
|
| 176 | 'date' => (string) $this->format_date( $media_item->post_modified_gmt, $media_item->post_modified ), |
|
| 177 | 'URL' => (string) wp_get_attachment_url( $media_item->ID ), |
|
| 178 | 'file' => (string) $file_paths['basename'], |
|
| 179 | 'extension' => (string) $file_paths['extension'], |
|
| 180 | 'mime_type' => (string) $media_item->post_mime_type, |
|
| 181 | 'size' => (int) filesize( $current_file ) |
|
| 182 | ); |
|
| 183 | ||
| 184 | return (object) $snapshot; |
|
| 185 | } |
|
| 186 | ||
| 187 | /** |
|
| 188 | * Try to remove the temporal file from the given file array. |
|
| @@ 233-247 (lines=15) @@ | ||
| 230 | * @param object $media_item - media post object |
|
| 231 | * @return object a revision item |
|
| 232 | */ |
|
| 233 | public static function get_snapshot( $media_item ) { |
|
| 234 | $current_file = get_attached_file( $media_item->ID ); |
|
| 235 | $file_paths = pathinfo( $current_file ); |
|
| 236 | ||
| 237 | $snapshot = array( |
|
| 238 | 'date' => (string) WPCOM_JSON_API_Date::format_date( $media_item->post_modified_gmt, $media_item->post_modified ), |
|
| 239 | 'URL' => (string) wp_get_attachment_url( $media_item->ID ), |
|
| 240 | 'file' => (string) $file_paths['basename'], |
|
| 241 | 'extension' => (string) $file_paths['extension'], |
|
| 242 | 'mime_type' => (string) $media_item->post_mime_type, |
|
| 243 | 'size' => (int) filesize( $current_file ) |
|
| 244 | ); |
|
| 245 | ||
| 246 | return (object) $snapshot; |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Add a new item into revision_history array. |
|