From db55eb6c47d0b50fff9ef85560236c2704a8253c Mon Sep 17 00:00:00 2001 From: Robert O'Rourke Date: Tue, 1 Jun 2021 15:08:04 +0000 Subject: [PATCH 1/2] Add Rekognition Labels to default weighting Fixes #125 --- inc/namespace.php | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/inc/namespace.php b/inc/namespace.php index bd6a98f..4a9ff75 100644 --- a/inc/namespace.php +++ b/inc/namespace.php @@ -69,6 +69,7 @@ function load_plugins() { add_filter( 'ep_post_sync_args_post_prepare_meta', __NAMESPACE__ . '\\add_rekognition_keywords_to_search_index', 10, 2 ); add_filter( 'ep_search_fields', __NAMESPACE__ . '\\add_rekognition_keywords_to_search_fields' ); add_filter( 'altis.search.autosuggest_post_fields', __NAMESPACE__ . '\\add_rekognition_keywords_to_autosuggest' ); + add_filter( 'ep_weighting_default_post_type_weights', __NAMESPACE__ . '\\add_rekognition_keywords_to_weighting_config', 10, 2 ); /** * Configure Rekognition features. @@ -190,6 +191,30 @@ function add_rekognition_keywords_to_autosuggest( array $fields ) : array { return $fields; } +/** + * Add rekognition labels and alt text to attachment searches by default. + * + * @param array $fields The field weighting config. + * @param string $post_type The post type to get defaults for. + * @return array + */ +function add_rekognition_keywords_to_weighting_config( array $fields, string $post_type ) : array { + if ( $post_type !== 'attachment' ) { + return $fields; + } + + $fields['alt'] = [ + 'enabled' => true, + 'weight' => 1.0, + ]; + $fields['rekognition_labels'] = [ + 'enabled' => true, + 'weight' => 1.0, + ]; + + return $fields; +} + /** * Load the safe SVG upload handler. */ From eaeb5a77b0e6e0e2751b5ca1b50a38cf63806085 Mon Sep 17 00:00:00 2001 From: Robert O'Rourke Date: Fri, 11 Jun 2021 11:54:38 +0000 Subject: [PATCH 2/2] bump