Skip to content

Commit

Permalink
Merge pull request #36 from wp-media/branch/1.5.10
Browse files Browse the repository at this point in the history
1.5.10
  • Loading branch information
remyperona authored Oct 3, 2016
2 parents b949527 + 296f39e commit d7ec2c2
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 28 deletions.
4 changes: 2 additions & 2 deletions imagify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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' );
Expand Down
2 changes: 1 addition & 1 deletion inc/admin/enqueue.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
27 changes: 2 additions & 25 deletions inc/admin/ui/options.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,31 +240,8 @@ function _imagify_display_options_page() {
<br>

<?php
$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,
);
}
}

$sizes = get_imagify_thumbnail_sizes();

foreach( $sizes as $size_key => $size_data ) {
$label = esc_html( stripslashes( $size_data['name'] ) );
$label = sprintf( '%s - %d &times; %d', $label, $size_data['width'], $size_data['height'] );
Expand Down
26 changes: 26 additions & 0 deletions inc/functions/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
39 changes: 39 additions & 0 deletions inc/functions/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
4 changes: 4 additions & 0 deletions readme.txt
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d7ec2c2

Please sign in to comment.