id = 'thinkrank/get-image-alt-text'; $this->label = __( 'Get ThinkRank Image Alt Text', 'thinkrank' ); $this->description = __( 'Read one image\'s alt text from the Media Library, along with its title, filename and URL. Use list-images to find ids, and update-image-alt-text to change the value.', 'thinkrank' ); } /** * {@inheritDoc} * * @return array */ public function get_annotations() { return [ 'readonly' => true, 'destructive' => false, 'idempotent' => true, 'priority' => 1.0, 'openWorldHint' => false, ]; } /** * {@inheritDoc} * * @return array */ public function get_input_schema() { return [ 'type' => 'object', 'additionalProperties' => false, 'required' => [ 'attachment_id' ], 'properties' => [ 'attachment_id' => [ 'type' => 'integer', 'description' => __( 'Attachment ID from list-images.', 'thinkrank' ), ], ], ]; } /** * {@inheritDoc} * * @return array */ public function get_output_schema() { return [ 'type' => 'object', 'properties' => $this->image_properties(), ]; } /** * Execute ability. * * @param array $input Ability input payload. * @return array|\WP_Error */ public function execute( $input ) { $attachment_id = (int) ( ( (array) $input )['attachment_id'] ?? 0 ); $rejection = $this->reject_if_not_an_image( $attachment_id ); if ( null !== $rejection ) { return $rejection; } return $this->describe_image( $attachment_id ); } }