Skip to content

Commit

Permalink
Merge pull request #130 from humanmade/backport-126-to-v6-branch
Browse files Browse the repository at this point in the history
[Backport v6-branch] Add Rekognition Labels to default weighting
  • Loading branch information
roborourke authored Jun 11, 2021
2 parents 777f3f7 + 74fda42 commit 7659aaa
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions inc/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit 7659aaa

Please sign in to comment.