| @@ 584-613 (lines=30) @@ | ||
| 581 | 'thumbnails' => array() |
|
| 582 | ); |
|
| 583 | ||
| 584 | if ( in_array( $ext, array( 'jpg', 'jpeg', 'png', 'gif' ) ) ) { |
|
| 585 | $metadata = wp_get_attachment_metadata( $media_item->ID ); |
|
| 586 | if ( isset( $metadata['height'], $metadata['width'] ) ) { |
|
| 587 | $response['height'] = $metadata['height']; |
|
| 588 | $response['width'] = $metadata['width']; |
|
| 589 | } |
|
| 590 | ||
| 591 | if ( isset( $metadata['sizes'] ) ) { |
|
| 592 | /** |
|
| 593 | * Filter the thumbnail sizes available for each attachment ID. |
|
| 594 | * |
|
| 595 | * @module json-api |
|
| 596 | * |
|
| 597 | * @since 3.9.0 |
|
| 598 | * |
|
| 599 | * @param array $metadata['sizes'] Array of thumbnail sizes available for a given attachment ID. |
|
| 600 | * @param string $media_id Attachment ID. |
|
| 601 | */ |
|
| 602 | $sizes = apply_filters( 'rest_api_thumbnail_sizes', $metadata['sizes'], $media_id ); |
|
| 603 | if ( is_array( $sizes ) ) { |
|
| 604 | foreach ( $sizes as $size => $size_details ) { |
|
| 605 | $response['thumbnails'][ $size ] = dirname( $response['URL'] ) . '/' . $size_details['file']; |
|
| 606 | } |
|
| 607 | } |
|
| 608 | } |
|
| 609 | ||
| 610 | if ( isset( $metadata['image_meta'] ) ) { |
|
| 611 | $response['exif'] = $metadata['image_meta']; |
|
| 612 | } |
|
| 613 | } |
|
| 614 | ||
| 615 | if ( in_array( $ext, array( 'mp3', 'm4a', 'wav', 'ogg' ) ) ) { |
|
| 616 | $metadata = wp_get_attachment_metadata( $media_item->ID ); |
|
| @@ 1242-1271 (lines=30) @@ | ||
| 1239 | 'thumbnails' => array() |
|
| 1240 | ); |
|
| 1241 | ||
| 1242 | if ( in_array( $ext, array( 'jpg', 'jpeg', 'png', 'gif' ) ) ) { |
|
| 1243 | $metadata = wp_get_attachment_metadata( $media_item->ID ); |
|
| 1244 | if ( isset( $metadata['height'], $metadata['width'] ) ) { |
|
| 1245 | $response['height'] = $metadata['height']; |
|
| 1246 | $response['width'] = $metadata['width']; |
|
| 1247 | } |
|
| 1248 | ||
| 1249 | if ( isset( $metadata['sizes'] ) ) { |
|
| 1250 | /** |
|
| 1251 | * Filter the thumbnail sizes available for each attachment ID. |
|
| 1252 | * |
|
| 1253 | * @module json-api |
|
| 1254 | * |
|
| 1255 | * @since 3.9.0 |
|
| 1256 | * |
|
| 1257 | * @param array $metadata['sizes'] Array of thumbnail sizes available for a given attachment ID. |
|
| 1258 | * @param string $media_id Attachment ID. |
|
| 1259 | */ |
|
| 1260 | $sizes = apply_filters( 'rest_api_thumbnail_sizes', $metadata['sizes'], $media_item->ID ); |
|
| 1261 | if ( is_array( $sizes ) ) { |
|
| 1262 | foreach ( $sizes as $size => $size_details ) { |
|
| 1263 | $response['thumbnails'][ $size ] = dirname( $response['URL'] ) . '/' . $size_details['file']; |
|
| 1264 | } |
|
| 1265 | } |
|
| 1266 | } |
|
| 1267 | ||
| 1268 | if ( isset( $metadata['image_meta'] ) ) { |
|
| 1269 | $response['exif'] = $metadata['image_meta']; |
|
| 1270 | } |
|
| 1271 | } |
|
| 1272 | ||
| 1273 | if ( in_array( $ext, array( 'mp3', 'm4a', 'wav', 'ogg' ) ) ) { |
|
| 1274 | $metadata = wp_get_attachment_metadata( $media_item->ID ); |
|