|
|
@@ -54,26 +54,26 @@ class Make_Endpoint_For extends WP_REST_Controller {
|
|
54
|
54
|
private function _getAttachments($item, $galleries) {
|
|
55
|
55
|
// Get media
|
|
56
|
56
|
$desiredSizes = ['thumbnail', 'medium', 'large', 'full'];
|
|
57
|
|
- $all_image_ids_in_gallery = array();
|
|
58
|
|
- $all_image_ids = array();
|
|
59
|
|
- foreach ($galleries as $gallery) {
|
|
60
|
|
- array_push($all_image_ids_in_gallery, $gallery[ids]);
|
|
|
57
|
+ $all_image_ids_in_gallery = array();
|
|
|
58
|
+ $all_image_ids = array();
|
|
|
59
|
+ foreach ($galleries as $gallery) {
|
|
|
60
|
+ array_push($all_image_ids_in_gallery, $gallery[ids]);
|
|
61
|
61
|
}
|
|
62
|
|
- foreach ($all_image_ids_in_gallery as $ids) {
|
|
63
|
|
- foreach ($ids as $id) {
|
|
64
|
|
- array_push($all_image_ids, $id);
|
|
65
|
|
- }
|
|
66
|
|
- }
|
|
67
|
|
- $attachment_map = array();
|
|
68
|
|
- foreach ($all_image_ids as $id) {
|
|
69
|
|
- $imageSizes = array();
|
|
|
62
|
+ foreach ($all_image_ids_in_gallery as $ids) {
|
|
|
63
|
+ foreach ($ids as $id) {
|
|
|
64
|
+ array_push($all_image_ids, $id);
|
|
|
65
|
+ }
|
|
|
66
|
+ }
|
|
|
67
|
+ $attachment_map = array();
|
|
|
68
|
+ foreach ($all_image_ids as $id) {
|
|
|
69
|
+ $imageSizes = array();
|
|
70
|
70
|
foreach ($desiredSizes as $size) {
|
|
71
|
71
|
$imageSizes[$size] = wp_get_attachment_image_url($id, $size);
|
|
72
|
|
- }
|
|
|
72
|
+ }
|
|
73
|
73
|
// store size:url map under image id
|
|
74
|
|
- $attachment_map[$id] = $imageSizes;
|
|
|
74
|
+ $attachment_map[$id] = $imageSizes;
|
|
75
|
75
|
}
|
|
76
|
|
- return $attachment_map;
|
|
|
76
|
+ return $attachment_map;
|
|
77
|
77
|
}
|
|
78
|
78
|
|
|
79
|
79
|
public function prepare_item_for_response( $args ) {
|