This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Image source settings

#22864
Ernest MarcinkoErnest Marcinko
Keymaster

Hi!

The issue is related to a custom code you have to get the taxonomy images within your theme functions.php file. Since the plugin does not find the image internally, it uses the default image. Then the custom code is executed, but since there is already an image, it is not in use. Try replacing it with this variation instead:

add_filter( "asp_results", "asp_acf_cf_image", 10, 1 ); 
function asp_acf_cf_image( $results ) {
    // Change this to the ACF custom field name
    $image_field = 'search_image';
    $default = 'https://domain.com/wp-content/plugins/ajax-search-pro/img/default.jpg';
    
    // ----------------------------------------------
    // --- Do not change anything below this line ---
    // ----------------------------------------------
    foreach ( $results as $k => &$r ) {
      if ( ( empty($r->image) || $r->image == $default ) && $r->content_type == 'term' ) {
        $img = get_field($image_field, $r->taxonomy . '_'.$r->id);
        if ( !empty($img) )
          $r->image = str_replace("'", "%27", $img);
      }
    }
    return $results;
}