Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added grayscale thumb option

  • Loading branch information...
commit 98371941c519151d16565ea8d92faf15955f142c 1 parent ebbb1f9
@sebastianberns sebastianberns authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 plugins/thumb/thumb.php
View
11 plugins/thumb/thumb.php
@@ -24,6 +24,7 @@ class thumb {
var $quality = 100;
var $alt = false;
var $crop = false;
+ var $grayscale = false;
function __construct($image, $options=array()) {
@@ -48,7 +49,10 @@ function __construct($image, $options=array()) {
// set the quality
$this->crop = @$options['crop'];
-
+
+ // set the quality
+ $this->grayscale = @$options['grayscale'];
+
// set the quality
$this->quality = a::get($options, 'quality', c::get('thumb.quality', 100));
@@ -87,6 +91,7 @@ function filename() {
$options .= ($this->maxHeight) ? '.' . $this->maxHeight : '.' . 0;
$options .= ($this->upscale) ? '.' . $this->upscale : '.' . 0;
$options .= ($this->crop) ? '.' . $this->crop : '.' . 0;
+ $options .= ($this->grayscale) ? '.' . $this->grayscale : '.' . 0;
$options .= '.' . $this->quality;
return md5($this->source) . $options . '.' . $this->obj->extension;
@@ -246,6 +251,10 @@ function create() {
imagefill($thumb, 0, 0, $color);
imagecopyresampled($thumb, $image, 0, 0, 0, 0, $this->width, $this->height, $this->sourceWidth, $this->sourceHeight);
}
+
+ if($this->grayscale == true) {
+ imagefilter($thumb, IMG_FILTER_GRAYSCALE);
+ }
switch($this->mime) {
case 'image/jpeg': imagejpeg($thumb, $file, $this->quality); break;
Please sign in to comment.
Something went wrong with that request. Please try again.