added get all selected endpoint
This commit is contained in:
parent
cacad4ed61
commit
a7f3618cf1
|
|
@ -3,12 +3,17 @@
|
||||||
namespace TheaterGF\Gallery\Backend;
|
namespace TheaterGF\Gallery\Backend;
|
||||||
|
|
||||||
require_once __DIR__ . '/endpoints/crop.php';
|
require_once __DIR__ . '/endpoints/crop.php';
|
||||||
|
require_once __DIR__ . '/endpoints/gallery.php';
|
||||||
|
|
||||||
add_action( 'rest_api_init', function () {
|
add_action( 'rest_api_init', function () {
|
||||||
$namespace = 'theatergf/gallery/v1';
|
$namespace = 'theatergf/gallery/v1';
|
||||||
|
|
||||||
$crop_controller = new Rest\CROP_Endpoints($namespace, 'images');
|
$crop_controller = new Rest\CROP_Endpoints($namespace, 'images');
|
||||||
$crop_controller->register_routes();
|
$crop_controller->register_routes();
|
||||||
|
|
||||||
|
$gallery_controller = new Rest\GALLERY_Endpoints($namespace, 'gallery');
|
||||||
|
$gallery_controller->register_routes();
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
add_action( 'delete_attachment', function ( $post_id ) {
|
add_action( 'delete_attachment', function ( $post_id ) {
|
||||||
|
|
|
||||||
|
|
@ -34,13 +34,17 @@ class GALLERY_Endpoints extends WP_REST_Controller {
|
||||||
'meta_key' => "_ttgf_gallery_selected",
|
'meta_key' => "_ttgf_gallery_selected",
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = []
|
$data = [];
|
||||||
|
|
||||||
foreach ( $posts as $post ) {
|
foreach ( $posts as $post ) {
|
||||||
$data[] = wp_get_attachment_image_src($post->ID, "full");
|
$img_data = wp_get_attachment_image_src($post->ID, "full");
|
||||||
|
if ($img_data !== false) {
|
||||||
|
$data[] = $img_data[0];
|
||||||
|
error_log($img_data[0] . " - " . $img_data[1] . "x" . $img_data[2] . " - resized: " . (int)$img_data[3]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue