PluginProbe
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF / trunk
Imagify Image Optimization: Optimize Images | Compress & Convert to WebP/AVIF vtrunk
2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.9 2.2.8 trunk 1.10 1.3.3 1.3.4 1.3.5 1.3.5.1 1.3.5.2 1.3.6 1.3.6.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 All 103 releases
← All changes | classes/Abilities/RestoreMedia.php +5 -6 2.3.2 → trunk View file →
@@ -36,12 +36,11 @@
36 36 'type' => 'object',
37 37 'properties' => [
38 38 'media_id' => [
39 39 'type' => 'integer',
40 - 'description' => __( 'The WordPress attachment ID to restore.', 'imagify' ),
40 + 'description' => __( 'The WordPress attachment ID to restore. Provide media_filename or media_url instead when the ID is unknown.', 'imagify' ),
41 41 ],
42 - ],
43 - 'required' => [ 'media_id' ],
42 + ] + MediaResolver::get_input_schema_properties(),
44 43 ],
45 44 'output_schema' => [
46 45 'type' => 'object',
47 46 'properties' => [
@@ -92,15 +91,15 @@
92 91 * @param array $args Input arguments. Expects `media_id` (int) — the WordPress attachment ID.
93 92 * @return array{status: string, restored_size: int|null, error_message: string|null}
94 93 */
95 94 public function execute( array $args = [] ): array {
96 - $media_id = isset( $args['media_id'] ) ? (int) $args['media_id'] : 0;
95 + $media_id = MediaResolver::resolve_id( $args );
97 96
98 - if ( $media_id <= 0 ) {
97 + if ( is_wp_error( $media_id ) ) {
99 98 return [
100 99 'status' => 'error',
101 100 'restored_size' => null,
102 - 'error_message' => 'Invalid or missing media_id.',
101 + 'error_message' => $media_id->get_error_message(),
103 102 ];
104 103 }
105 104
106 105 $process = $this->get_process( $media_id );