Show image for taxonomy pages in Ajax Search Pro

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Show image for taxonomy pages in Ajax Search Pro

This topic contains 4 replies, has 2 voices, and was last updated by remkovdz remkovdz 7 years, 6 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #4147
    remkovdz
    remkovdz
    Participant

    I’d like the live search results for taxonomies to show an image.

    When you search for ‘Slips’ you the result ‘Slips’ returned. This page has a thumbnail set I’d like to be displayed.

    #4151
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi!

    I can’t seem to log in to the site, it requests .htaccess authentication. Could you please check that, or upload a txt file with authentication details?

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #4152
    remkovdz
    remkovdz
    Participant

    .htaccess credentials are in the popup 😉

    #4154
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you 😉

    After some debugging I was able to find the storage method of the images. I’ve implemented the following code to your themes functions.php file:

    
    add_filter( "asp_results", "asp_extra_terms_image_results", 1, 1 );
         
    function asp_extra_terms_image_results( $results ) {
       
      foreach ($results as $k=>$v) {
        // get the term images
        if ($results[$k]->image != null && $results[$k]->image != "")
           continue;
         
        /* Try to get woocommerce image */   
        $x = get_woocommerce_term_meta( (int)$v->id, 'thumbnail_id', true );
        if ($x != "")  {
          $im = wp_get_attachment_url( $x );
          if ($im != '') {
            $bfi_params = array('width' => 70, 'height' => 70, 'crop' => true);
            $results[$k]->image = bfi_thumb($im, $bfi_params);
          }
        }
        
        /* Other term image then.. */
        $x = get_metadata("woocommerce_term", (int)$v->id);
        if (isset($x['pa_merk_thumbnail_id_photo'][0])) {
          $im = wp_get_attachment_url( $x['pa_merk_thumbnail_id_photo'][0] );
          if ($im != '') {
            $bfi_params = array('width' => 70, 'height' => 70, 'crop' => true);
            $results[$k]->image = bfi_thumb($im, $bfi_params);
          }
        }
                    
      }
         
      return $results;
    }
    

    Since it is placed into the themes functions.php file, this code will remain in case of updating the search plugin.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #4155
    remkovdz
    remkovdz
    Participant

    Works great, thanks!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Show image for taxonomy pages in Ajax Search Pro’ is closed to new replies.