$image->alt, self::PEXELS_PHOTOGRAPHER => $image->photographer, self::PEXELS_PHOTOGRAPHER_URL => $image->photographer_url, self::PEXELS_ID => $image->id, ]; foreach ( $meta as $meta_key => $value ) { if ( strlen( (string) $value ) <= 0 ) { continue; } update_post_meta( $attachment_id, $meta_key, wp_slash( sanitize_text_field( $value ) ) ); } } /** * Delete image metadata. * * @param int $attachment_id * * @return void */ public function delete( int $attachment_id ): void { foreach ( self::DELETABLE as $meta_key ) { delete_post_meta( $attachment_id, $meta_key ); } } }