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

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?

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

    Hi,

    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?

    Thanks

    #6637
    Ernest MarcinkoErnest 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: http://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:

    [php]
    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;
    }
    [/php]

    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:

    [code]$size = array(64, 64);[/code]

    I’m not sure if that works though.

    #6638
    aaronjpittsaaronjpitts
    Participant

    Perfect, thank you!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.