How can I set which image size the results thumbnail uses?

Home Forums Product Support Forums Ajax Search Pro for WordPress Support How can I set which image size the results thumbnail uses?

This topic contains 2 replies, has 2 voices, and was last updated by aaronjpitts aaronjpitts 8 years, 6 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • #6636


    In the results listing, the image for the product results uses the full original image which is a complete waste of bandwidth. How can I set it so that $r->image outputs the thumbnail size image for example?


    Ernest Marcinko
    Ernest Marcinko


    You have two options in this case.

    1. By default the image cropping is disabled to save CPU over bandwith, you can enable it on the Cache Settings submenu:

    2. Don’t use the cropping, nor the original images by adding this filter function to your themes functions.php file:

    add_filter( 'asp_pagepost_results', 'asp_get_thumb_image', 1, 1 );
    function asp_get_thumb_image( $pageposts ) {
      // Possible values: thumbnail, medium, large, or full 
      $size = "thumbnail";
      foreach ($pageposts as $k=>$v) {
        $url = wp_get_attachment_image_src( get_post_thumbnail_id($v->id), $size );
        if ( !empty($url[0]) ) {
            $pageposts[$k]->image = $url[0];
      return $pageposts;

    You can change the $size variable in the code to “thumbnail”, “medium”, “large”, or “full”, those are WordPress supported values. I believe the thumbnail is 150×150, the medium is 300×300 and so on..

    If you want smaller than 150×150, then the WordPress codex states that an array of dimensions should be given, like so:

    $size =  array(64, 64);

    I’m not sure if that works though.

    Ernest Marcinko

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


    Perfect, thank you!

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

You must be logged in to reply to this topic.