added get all selected endpoint

This commit is contained in:
Patrick 2026-05-20 13:53:26 +02:00
parent cacad4ed61
commit a7f3618cf1
2 changed files with 12 additions and 3 deletions

View File

@ -3,12 +3,17 @@
namespace TheaterGF\Gallery\Backend;
require_once __DIR__ . '/endpoints/crop.php';
require_once __DIR__ . '/endpoints/gallery.php';
add_action( 'rest_api_init', function () {
$namespace = 'theatergf/gallery/v1';
$crop_controller = new Rest\CROP_Endpoints($namespace, 'images');
$crop_controller->register_routes();
$gallery_controller = new Rest\GALLERY_Endpoints($namespace, 'gallery');
$gallery_controller->register_routes();
});
add_action( 'delete_attachment', function ( $post_id ) {

View File

@ -34,13 +34,17 @@ class GALLERY_Endpoints extends WP_REST_Controller {
'meta_key' => "_ttgf_gallery_selected",
));
$data = []
$data = [];
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;
}
}