diff --git a/readme.txt b/readme.txt index 45434d4..715c07e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ 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.1 +Stable tag: 0.2 License: GPLv3 License URI: http://www.gnu.org/licenses/gpl-3.0.html Required minimum PHP version: 5.3 @@ -40,6 +40,11 @@ Version numbering logic: * every .B version indicates new features. * every ..C indicates bugfixes for A.B version. += 0.2 = +*2016-03-01* + +* setting resized images to be interlaced + = 0.1 = *2015-12-10* diff --git a/wp-resited2cache.php b/wp-resited2cache.php index 5c47316..4fc172e 100644 --- a/wp-resited2cache.php +++ b/wp-resited2cache.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.1 +Version: 0.2 Author: Peter Molnar Author URI: http://petermolnar.eu/ License: GPLv3 @@ -140,6 +140,7 @@ class WP_RESIZED2CACHE { $imagick->setImageFormat("jpg"); $imagick->setImageCompression(Imagick::COMPRESSION_JPEG); $imagick->setImageCompressionQuality(static::jpeg_quality()); + $imagick->setInterlaceScheme(Imagick::INTERLACE_PLANE); $imagick->writeImage($cached); $imagick->destroy(); } @@ -173,23 +174,54 @@ class WP_RESIZED2CACHE { * * @param string $message * @param int $level + * + * @output log to syslog | wp_die on high level + * @return false on not taking action, true on log sent */ - static function debug( $message, $level = LOG_NOTICE ) { + public static function debug( $message, $level = LOG_NOTICE ) { + if ( empty( $message ) ) + return false; + if ( @is_array( $message ) || @is_object ( $message ) ) $message = json_encode($message); + $levels = array ( + LOG_EMERG => 0, // system is unusable + LOG_ALERT => 1, // Alert action must be taken immediately + LOG_CRIT => 2, // Critical critical conditions + LOG_ERR => 3, // Error error conditions + LOG_WARNING => 4, // Warning warning conditions + LOG_NOTICE => 5, // Notice normal but significant condition + LOG_INFO => 6, // Informational informational messages + LOG_DEBUG => 7, // Debug debug-level messages + ); - switch ( $level ) { - case LOG_ERR : - wp_die( '

Error:

' . '

' . $message . '

' ); - exit; - default: - if ( !defined( 'WP_DEBUG' ) || WP_DEBUG != true ) - return; - break; + // number for number based comparison + // should work with the defines only, this is just a make-it-sure step + $level_ = $levels [ $level ]; + + // in case WordPress debug log has a minimum level + if ( defined ( 'WP_DEBUG_LEVEL' ) ) { + $wp_level = $levels [ WP_DEBUG_LEVEL ]; + if ( $level_ < $wp_level ) { + return false; + } } - error_log( __CLASS__ . " => " . $message ); + // ERR, CRIT, ALERT and EMERG + if ( 3 >= $level_ ) { + wp_die( '

Error:

' . '

' . $message . '

' ); + exit; + } + + $trace = debug_backtrace(); + $caller = $trace[1]; + $parent = $caller['function']; + + if (isset($caller['class'])) + $parent = $caller['class'] . '::' . $parent; + + return error_log( "{$parent}: {$message}" ); } /**