Easy WP Thumbs

PHP Script

WordPress thumbnails, made easy!

Easy WP Thumbs is a PHP script created with the purpose to make WordPress thumbnails creation process as easy and smooth as possible.
Inspired by TimThumb, is based on WP systems for the maximum compatibility.

Requires at least WordPress 3.5 and PHP 5.2
Supports WP_Image_Editor class, using Imagick where available.

Currently you can see this script implemented in Media Grid and Global Gallery

How to use

  1. include easy_wp_thumbs.php in the main plugin/theme file

  2. on common servers you are ready to go, move to step 3.
    While on hostings preventing direct files access you must check script status and, eventually, insert FTP/SSH credentials

    // (optional) setup WP multilang functions to target your multilang domain 
    ewpt_status_panel::$multilang_key = 'your_multilanguage_key'; 
    // print status panel. $wrap_with_form_tag = false if you are putting it in an existing form 
    echo ewpt_status_panel::get($wrap_with_form_tag = false); 

  3. Create thumbnails

    // inline PHP function returning static image URL
    easy_wp_thumb($img_src, $width, $height, $quality, $alignment, $resize, $canvas_col, $fx);
    // alternative way, using parameters array. You may use all of them or only few
    $params = array(
        'w' => (int|bool),
        'h' => (int|bool),
        'q' => (int),
        'a' => (string),
        'rs' => (int),
        'cc' => (string),
        'fx' =>(array),
        'get_url_if_not_cached'=>  (string|bool)
    easy_wp_thumb($img_src, $params);
    // Timthumb-like async thumb creation (useful to not weight tons of processes on a single page)
    <img src="<?php echo 'SCRIPT-URL/easy_wp_thumbs.php?src= &w= &h= &q= &a= &rs= &cc= &fx=' ?>" />


ParameterDefault ValueDescription
$img_src / src//Image source. Could be the WP image ID or the image path/url(required)
$width / wImage’s widthThumbnail’s width
$height / hImage’s heightThumbnail’s height
$quality / q80Thumbnail’s quality in a scale of 0-100
$alignment / acCrop alignment. Possible values: tl, t, tr, l, c, r, bl, b, brc = center, t = top, b = bottom, r = right, l = left
$resize / rs1Resize method1 = Resize and crop2 = Resize and add borders3 = Only resize
$canvas_col / ccFFFFFFBackground / borders color – use hexadecimal values
$fx / fxnoneEffects applied to the image
  • 1 = grayscale
  • 2 = blur
Must be used with commas. Ex: $fx = 1,2,2,2
$get_url_if_not_cachedfalseWhether to return remote thumb URL if image is not cached, to avoid page’s opening slowdowns.
Use false or the easy_wp_thumbs.php file URL