GithubHelp home page GithubHelp logo

th3fallen / bfi_thumb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bfintal/bfi_thumb

0.0 2.0 0.0 165 KB

WP Image Resizer & a replacement for Timthumb. Extends and uses the default capabilities of WordPress' Image Editors to add some basic Timthumb capabilities.

Home Page: http://bfintal.github.com/bfi_thumb/

License: GNU General Public License v3.0

PHP 100.00%

bfi_thumb's Introduction

bfi_thumb

On the fly image resizer / cropper / grayscaler / colorizer / opacitor :) for WordPress

Supports WordPress 3.5+

Bfi_thumb resizes image on the fly using WordPress' Image Editor classes, thus supports both Imagick and GD and switches automatically depending on what's available. The default Image Editors only have a handful of basic functions (crop, resize, rotate, etc), bfi_thumb also extends these classes to include these new functions:

  • Grayscale
  • Color (colorize)
  • Opacity
  • Negate
  • Resize images down or UP

Bfi_thumb stores previously created images in WP's default uploads directory, and uses those for future calls. The script automatically checks for updates on the original image then re-creates new images when needed. Any image can be used as long it is in your WordPress instance.

The code was inspired by the awesome Aqua Resizer


Demo

My themes usee BFI Thumb to generate all it's images:


Why Make a New One?

Aqua Resizer is awesome, WP's Image Editor is awesome, Timthumb is awesome.

When WP reached 3.5 and introduced the Image Editor class, as a theme author I couldn't anymore use Timthumb in my WP themes. An alternative was to use Aqua Resizer instead. Although it did the job quite well, I needed some of the functionalities supported by Timthumb.. I needed to be allowed to grayscale, color tint images and change the opacity of images all while resizing them. I couldn't find anything that did everything I wanted, so I made BFI_Thumb.


Usage

  1. Include / require BFI_Thumb.php into your WordPress files.
require_once('BFI_Thumb.php');
  1. Call the function to get the image URL
$params = { 'width' => 400 };
echo "<img src='" . bfi_thumb( "URL-to-image.jpg", $params ) . "'/>";

$params is an associative array containing the actions to perform on your image.

Examples:

// Resize by width only
$params = {'width' => 400};
bfi_thumb("URL-to-image.jpg", $params);

// Resize by width and height
$params = {'width' => 400, 'height' => 300};
bfi_thumb("URL-to-image.jpg", $params);

// Crop
$params = {'width' => 400, 'height' => 300, 'crop' => true};
bfi_thumb("URL-to-image.jpg", $params);

// Change opacity (makes your image into a PNG)
$params = {'opacity' => 80}; // 80% opaque
bfi_thumb("URL-to-image.jpg", $params);

// Grayscale
$params = {'grayscale' => true};
bfi_thumb("URL-to-image.jpg", $params);

// Colorize
$params = {'color' => '#ff0000'};
bfi_thumb("URL-to-image.jpg", $params);

// Negate
$params = {'negate' => true};
bfi_thumb("URL-to-image.jpg", $params);

// Multiple parameters
$params = {'width' => 400, 'height' => 300, 'opacity' => 50, 'grayscale' => true, 'colorize' => '#ff0000'};
bfi_thumb("URL-to-image.jpg", $params);

License

GPL 3.0

It's not required but I appreciate if you attribute and/or link back if you find this helpful :)


Social Stuff

Twitter: @bfintal & @gambitph

bfi_thumb's People

Contributors

bfintal avatar th3fallen avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.