all repos — wp-resized2cache @ 8510c6e8a6b2199651d8b9705a587fd5b77e87de

name fix + better debugging
Peter Molnar hello@petermolnar.eu
Tue, 08 Mar 2016 13:45:02 +0000
commit

8510c6e8a6b2199651d8b9705a587fd5b77e87de

parent

ec16fd2fee94997a2cfa6811ff98f959bead2ec0

2 files changed, 20 insertions(+), 15 deletions(-)

jump to
M readme.txtreadme.txt

@@ -3,8 +3,8 @@ Contributors: cadeyrn

Donate link: https://paypal.me/petermolnar/3 Tags: image, cache, image quality, Requires at least: 3.0 -Tested up to: 4.4 -Stable tag: 0.2 +Tested up to: 4.4.2 +Stable tag: 0.2.1 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Required minimum PHP version: 5.3

@@ -39,6 +39,11 @@

* every A. indicates BIG changes. * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. + += 0.2.1 = +*2016-03-08* + +* better debugging = 0.2 = *2016-03-01*
M wp-resited2cache.phpwp-resized2cache.php

@@ -3,7 +3,7 @@ /*

Plugin Name: wp-resized2cache Plugin URI: https://github.com/petermolnar/wp-resized2cache Description: Sharpen, enchance and move resized images to cache folder -Version: 0.2 +Version: 0.2.1 Author: Peter Molnar <hello@petermolnar.eu> Author URI: http://petermolnar.eu/ License: GPLv3

@@ -37,7 +37,7 @@ register_activation_hook( __FILE__ , array( &$this, 'plugin_activate' ) );

if (!is_dir(static::cachedir)) { if (!mkdir(static::cachedir)) { - static::debug('failed to create ' . static::cachedir); + static::debug('failed to create ' . static::cachedir, 4); } }

@@ -70,7 +70,7 @@ * called on attachment deletion and takes care of removing the moved files

* */ public static function delete_from_cache ( $aid = null ) { - static::debug( "DELETE is called and aid is: " . $aid ); + static::debug( "DELETE is called and aid is: " . $aid, 5 ); if ($aid === null) return false;

@@ -83,7 +83,7 @@ if (isset($meta['sizes']) && !empty($meta['sizes'])) {

foreach ( $meta['sizes'] as $size => $data ) { $file = static::cachedir . DIRECTORY_SEPARATOR . $data['file']; if ( isset($data['file']) && is_file($file)) { - static::debug( " removing " . $file ); + static::debug( " removing " . $file, 5 ); unlink ($file); } }

@@ -107,7 +107,7 @@ */

static public function sharpen( $resized ) { if (!class_exists('Imagick')) { - static::debug('Please install Imagick extension; otherwise this plugin will not work as well as it should.'); + static::debug('Please install Imagick extension; otherwise this plugin will not work as well as it should.', 4); } /*

@@ -123,7 +123,7 @@

$size = @getimagesize($resized); if ( !$size ) { - static::debug("Unable to get size"); + static::debug("Unable to get size for: {$resized}", 4); return $resized; }

@@ -133,7 +133,7 @@ $fname = basename( $resized );

$cached = static::cachedir . DIRECTORY_SEPARATOR . $fname; if ( $size[2] == IMAGETYPE_JPEG && class_exists('Imagick')) { - static::debug( "adaptive sharpen " . $resized ); + static::debug( "adaptive sharpen " . $resized, 6 ); try { $imagick = new Imagick($resized); $imagick->unsharpMaskImage(0,0.5,1,0);

@@ -145,22 +145,22 @@ $imagick->writeImage($cached);

$imagick->destroy(); } catch (Exception $e) { - static::debug( 'something went wrong with imagemagick: ', $e->getMessage() ); + static::debug( 'something went wrong with imagemagick: ', $e->getMessage(), 4 ); return $resized; } - static::debug( "removing " . $resized ); + static::debug( "removing " . $resized, 5 ); unlink ($resized); } else { - static::debug( "moving " . $cached ); + static::debug( "moving " . $cached, 5 ); if (copy( $resized, $cached)) { - static::debug( "removing " . $resized ); + static::debug( "removing " . $resized, 5 ); unlink( $resized ); } else { - static::debug( "\tmove failed, passing on this" ); + static::debug( "\tmove failed, passing on this", 4 ); } }

@@ -203,7 +203,7 @@

// in case WordPress debug log has a minimum level if ( defined ( 'WP_DEBUG_LEVEL' ) ) { $wp_level = $levels [ WP_DEBUG_LEVEL ]; - if ( $level_ < $wp_level ) { + if ( $level_ > $wp_level ) { return false; } }