AppThemes Docs

Add 3rd Party Thumbnail Services into Clipper

Clipper by default uses WordPress mShots to generate and display store thumbnails. But with a little modification, you can use anyone of the following thumbnail services: thumbshots.com, screenshotmachine.com, robothumb.com, etc.

In this tutorial we will show how to change the default image of stores (which is displayed when store have no url), and how to replace the mShots thumbnails with thumbnails from PagePeeker.com – a free thumbnail service (various plans available).

IN Clipper 1.3.2 we have added two new hooks that allow us to modify store thumbnails:

Getting Started

Before starting, you need to create a child theme. This will avoid modifying any of your core files.

All the HTML/PHP code in this tutorial should be added to your child-theme functions.php file.

Replacing default store image

For this purpose we have to use the clpr_store_default_image filter which passes 2 arguments:

But before we override the Clipper default store image, please open Your favorite photo editing software and create your own default image to display when no thumbnail for a particular store.
In Clipper we use 4 sizes:

After You create your default images, upload them to “images” folder of your child theme.

As a last step copy and paste the code below into functions.php of your child theme.

//changes default image of stores
function child_store_default_image($store_image_url, $width) {
  //choose right size
  switch( $width ) :
    case '250':
      $size = '250x190';
      break;
    case '160':
      $size = '160x120';
      break;
    case '150':
      $size = '150x110';
      break;
    default:
      $size = '110x90';
      break;
  endswitch;
 
  $store_image_url = get_stylesheet_directory_uri() . "/images/" . $size . ".jpg";
 
  return $store_image_url;
}
add_filter('clpr_store_default_image', 'child_store_default_image', 10, 2);

Use PagePeeker as web thumbnails service

For this purpose we have to use clpr_store_image filter which passes 3 arguments:

PagePeeker offers predefined sizes of thumbnails (other sizes available for premium accounts):

We will use then size ‘s’ on lists with coupons, and size ‘m’ in all other places – thumbnails will be resized to the size you want using CSS.

Now, copy and paste the code below into functions.php of your child theme.

//changes store thumbnail, allows to add 3-rd party services, below PagePeeker
function child_store_image($store_image_url, $width, $store_url) {
  //choose right size
  switch( $width ) :
    case '110':
      $size = 's';
      break;
    default:
      $size = 'm';
      break;
  endswitch;
 
  $store_image_url = 'http://pagepeeker.com/thumbs.php?size=' . $size . '&url=' . $store_url;
 
  return $store_image_url;
}
add_filter('clpr_store_image', 'child_store_image', 10, 3);

Save file and refresh your site to see the changes. Enjoy!

Like this tutorial? Subscribe and get the latest tutorials delivered straight to your inbox or feed reader.

Your rating: none
Rating: 3.2 - 10 votes