PluginProbe
Image Optimizer – Compress Images and Convert to WebP or AVIF / trunk
Image Optimizer – Compress Images and Convert to WebP or AVIF vtrunk
1.7.7 1.7.6 1.7.5 1.7.4 trunk 1.0.0 1.0.1 1.0.2 1.1.0 1.2.0 1.2.1 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 All 33 releases
image-optimization / modules / optimization / rest / get-bulk-optimization-images.php

get-bulk-optimization-images.php in Image Optimizer – Compress Images and Convert to WebP or AVIF trunk, at modules/optimization/rest/get-bulk-optimization-images.php

48 lines 922 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace ImageOptimization\Modules\Optimization\Rest;
4
5 use ImageOptimization\Modules\Optimization\Classes\{
6 Bulk_Optimization\Bulk_Optimization_Controller,
7 Route_Base,
8 };
9
10 use Throwable;
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit; // Exit if accessed directly.
14 }
15
16 class Get_Bulk_Optimization_Images extends Route_Base {
17 protected string $path = 'bulk/images';
18
19 public function get_name(): string {
20 return 'bulk-optimization-images';
21 }
22
23 public function get_methods(): array {
24 return [ 'GET' ];
25 }
26
27 public function GET() {
28 $error = $this->verify_capability();
29
30 if ( $error ) {
31 return $error;
32 }
33
34 try {
35 $images = Bulk_Optimization_Controller::get_processed_images();
36
37 return $this->respond_success_json([
38 'images' => $images,
39 ]);
40 } catch ( Throwable $t ) {
41 return $this->respond_error_json([
42 'message' => $t->getMessage(),
43 'code' => 'internal_server_error',
44 ]);
45 }
46 }
47 }
48