diff --git a/imagify.php b/imagify.php index e05c07ca8..8e4bb0bcb 100644 --- a/imagify.php +++ b/imagify.php @@ -3,7 +3,7 @@ Plugin Name: Imagify Plugin URI: https://wordpress.org/plugins/imagify/ Description: Dramaticaly reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwith using Imagify, the new most advanced image optimization tool. -Version: 1.5.9 +Version: 1.5.10 Author: WP Media Author URI: http://wp-media.me Licence: GPLv2 @@ -17,7 +17,7 @@ defined( 'ABSPATH' ) or die( 'Cheatin\' uh?' ); // Imagify defines -define( 'IMAGIFY_VERSION' , '1.5.9' ); +define( 'IMAGIFY_VERSION' , '1.5.10' ); define( 'IMAGIFY_SLUG' , 'imagify' ); define( 'IMAGIFY_SETTINGS_SLUG' , IMAGIFY_SLUG . '_settings' ); define( 'IMAGIFY_WEB_MAIN' , 'https://imagify.io' ); diff --git a/inc/admin/enqueue.php b/inc/admin/enqueue.php old mode 100644 new mode 100755 index 76fb9b05e..e8aff5f8a --- a/inc/admin/enqueue.php +++ b/inc/admin/enqueue.php @@ -175,7 +175,7 @@ function _imagify_admin_print_styles() { * * @since 1.5.4 */ - $bulk_data['buffer_size'] = apply_filters( 'imagify_bulk_buffer_size', 4 ); + $bulk_data['buffer_size'] = apply_filters( 'imagify_bulk_buffer_size', get_imagify_bulk_buffer_size() ); wp_localize_script( 'imagify-js-bulk', 'imagifyBulk', $bulk_data ); wp_enqueue_script( 'imagify-js-chart' ); diff --git a/inc/admin/ui/options.php b/inc/admin/ui/options.php index 2ca92faa0..9be8259c7 100755 --- a/inc/admin/ui/options.php +++ b/inc/admin/ui/options.php @@ -240,31 +240,8 @@ function _imagify_display_options_page() {
= 0; - $all_intermediate_image_sizes = get_intermediate_image_sizes(); - $intermediate_image_sizes = apply_filters( 'image_size_names_choose', $all_intermediate_image_sizes ); - $all_intermediate_image_sizes = array_combine( $all_intermediate_image_sizes, $all_intermediate_image_sizes ); - $intermediate_image_sizes = array_merge( $all_intermediate_image_sizes, $intermediate_image_sizes ); - $wp_image_sizes = $is_wp44 ? array( 'thumbnail', 'medium', 'medium_large', 'large' ) : array( 'thumbnail', 'medium', 'large' ); - - // Create the full array with sizes and crop info - foreach ( $intermediate_image_sizes as $size => $size_name ) { - if ( in_array( $size, $wp_image_sizes ) && ! is_int( $size ) ) { - $sizes[ $size ] = array( - 'width' => get_option( $size . '_size_w' ), - 'height' => get_option( $size . '_size_h' ), - 'name' => $size_name, - ); - } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) { - $sizes[ $size ] = array( - 'width' => $_wp_additional_image_sizes[ $size ]['width'], - 'height' => $_wp_additional_image_sizes[ $size ]['height'], - 'name' => $size_name, - ); - } - } - + $sizes = get_imagify_thumbnail_sizes(); + foreach( $sizes as $size_key => $size_data ) { $label = esc_html( stripslashes( $size_data['name'] ) ); $label = sprintf( '%s - %d × %d', $label, $size_data['width'], $size_data['height'] ); diff --git a/inc/functions/admin.php b/inc/functions/admin.php index 9d49fc391..14e12b287 100755 --- a/inc/functions/admin.php +++ b/inc/functions/admin.php @@ -161,4 +161,30 @@ function imagify_query_results_combine( $keys, $values ) { } return $result; +} + +/** + * Get the default Bulk Optimization buffer size. + * + * @since 1.5.10 + * @author Jonathan Buttigieg + * + * @return int The buffer size + */ +function get_imagify_bulk_buffer_size() { + $sizes = count( get_imagify_thumbnail_sizes() ); + + switch ( true ) { + case ( $sizes >= 10 ) : + return 1; + break; + case ( $sizes >= 8 ) : + return 2; + break; + case ( $sizes >= 6 ) : + return 3; + break; + default: + return 4; + } } \ No newline at end of file diff --git a/inc/functions/attachments.php b/inc/functions/attachments.php index 794b54300..e3f253b3a 100755 --- a/inc/functions/attachments.php +++ b/inc/functions/attachments.php @@ -91,4 +91,43 @@ function get_imagify_attachment_url( $filename ) { } return $url; +} + +/* + * Get size information for all currently-registered thumbnail sizes. + * + * @since 1.5.10 + * @author Jonathan Buttigieg + * + * @return array Data for all currently-registered thumbnail sizes. + */ +function get_imagify_thumbnail_sizes() { + global $_wp_additional_image_sizes; + + $sizes = array(); + $is_wp44 = version_compare( $wp_version, '4.4-beta3' ) >= 0; + $all_intermediate_image_sizes = get_intermediate_image_sizes(); + $intermediate_image_sizes = apply_filters( 'image_size_names_choose', $all_intermediate_image_sizes ); + $all_intermediate_image_sizes = array_combine( $all_intermediate_image_sizes, $all_intermediate_image_sizes ); + $intermediate_image_sizes = array_merge( $all_intermediate_image_sizes, $intermediate_image_sizes ); + $wp_image_sizes = $is_wp44 ? array( 'thumbnail', 'medium', 'medium_large', 'large' ) : array( 'thumbnail', 'medium', 'large' ); + + // Create the full array with sizes and crop info + foreach ( $intermediate_image_sizes as $size => $size_name ) { + if ( in_array( $size, $wp_image_sizes ) && ! is_int( $size ) ) { + $sizes[ $size ] = array( + 'width' => get_option( $size . '_size_w' ), + 'height' => get_option( $size . '_size_h' ), + 'name' => $size_name, + ); + } elseif ( isset( $_wp_additional_image_sizes[ $size ] ) ) { + $sizes[ $size ] = array( + 'width' => $_wp_additional_image_sizes[ $size ]['width'], + 'height' => $_wp_additional_image_sizes[ $size ]['height'], + 'name' => $size_name, + ); + } + } + + return $sizes; } \ No newline at end of file diff --git a/readme.txt b/readme.txt old mode 100644 new mode 100755 index f9bfd5c1a..ced154e9d --- a/readme.txt +++ b/readme.txt @@ -135,6 +135,10 @@ When the plugin is disabled, your existing images remain optimized. Backups of t 3. Media Page == Changelog == += 1.5.10 = +* Improvement + * Set to 1 the Bulk buffer size when there are more than 10 thumbnails to avoid "Unkown error" on the Bulk Optimization + = 1.5.9 = * Bug fix * Don't delete the thumbnail when the maximum file size is set to one of the thumbnail size