API – Thumbnail – Introduction

Available on: Newsmag V1.8+, Newspaper V5+

The td_api_thumb class allows you to add or modify a thumbnail. The thumbnails are used on modules which appear on loops and on blocks:

td_api_thumbs_fontend

In Theme Panel you can find an option to disable cropping for the thumbs you don’t use. If you add a new thumb it will look like this:

td_api_thumbs_new_backend

The theme thumbnails are registered in td_config.php, the code looks like this:

td_api_thumb::add('td_100x75',
    array(
        'name' => 'td_100x75',
        'width' => 100,
        'height' => 75,
        'crop' => array('center', 'top'),
        'post_format_icon_size' => 'small',
        'used_on' => array(
            'Module 6, 7', 'Block 1, 2, 7, 8'
        )
    )
);

Parameters:

$id (string) (required)

  • the thumbnail id – if you add a new thumbnail the id has to be different from the ones used on the other thumbnails which are registered in theme, if you plan to modify one of the existing thumbnails the id has to match with the one you’re planing to modify.

$params_array (array) (required)

  • an array which contains the parameters of the thumbnail:
Key name
Type
Description
name string the thumbnail name
width integer the thumbnail width in pixels
height integer the thumbnail height in pixels
crop mixed the cropping method (array, true or false), it is passed to the add_image_size() function, for more information check the following resources – functionextra
post_format_icon_size string specify what play icon to load for video posts (small or normal)
used_on array the locations on which thumb appears, it’s just an info and appears in Theme Panel -> Block Settings