Reply To: 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? Reply To: How can I set which image size the results thumbnail uses?

#6637

Ernest Marcinko
Keymaster

Hi!

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: https://i.imgur.com/UIMicxB.png

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.

Best,
Ernest Marcinko

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