Plugin Updates
This commit is contained in:
@@ -1445,11 +1445,6 @@ ul.imagify-datas-details.imagify-datas-details {
|
||||
}
|
||||
|
||||
/* Attachments specifics */
|
||||
.wp_attachment_image #imagify-visual-comparison .close-btn,
|
||||
.imagify-visual-comparison .close-btn {
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.wp_attachment_image #imagify-visual-comparison .imagify-modal-content,
|
||||
.imagify-visual-comparison .imagify-modal-content {
|
||||
padding-top: 40px;
|
||||
@@ -1585,3 +1580,11 @@ ul.imagify-datas-details.imagify-datas-details {
|
||||
.imagify-upsell .imagify-meteo-icon {
|
||||
filter: invert(100%) sepia(100%) saturate(0%) hue-rotate(104deg) brightness(103%) contrast(103%);
|
||||
}
|
||||
|
||||
.imagify-original-fize-size {
|
||||
display: block !important;
|
||||
}
|
||||
|
||||
.imagify-original-fize-size .value {
|
||||
padding-left: 15px !important;
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -211,7 +211,7 @@
|
||||
modalHtml += '<img class="imagify-img-after" alt="" width="' + settings.width + '" height="' + settings.height + '">';
|
||||
modalHtml += '</div>';
|
||||
modalHtml += '<div class="imagify-comparison-levels">';
|
||||
modalHtml += '<div class="imagify-c-level imagify-level-original go-left">';
|
||||
modalHtml += '<div class="imagify-c-level imagify-level-original go-left imagify-original-fize-size">';
|
||||
modalHtml += '<p class="imagify-c-level-row">';
|
||||
modalHtml += '<span class="label">' + imagifyTTT.labels.filesize + '</span>';
|
||||
modalHtml += '<span class="value level">' + settings.originalSize + '</span>';
|
||||
@@ -515,7 +515,7 @@
|
||||
// If shown image > 360, use twentytwenty.
|
||||
if ( imagifyTTT.imageWidth > imagifyTTT.widthLimit && oriSource.src ) {
|
||||
|
||||
filesize = $( '.misc-pub-filesize strong' ).text();
|
||||
filesize = $( '#imagify-full-optimized-size' ).val();
|
||||
saving = $( '.imagify-data-item .imagify-chart-value' ).text();
|
||||
|
||||
// Create button to trigger.
|
||||
@@ -574,7 +574,7 @@
|
||||
originalUrl: $this.data( 'backup-src' ),
|
||||
optimizedUrl: $this.data( 'full-src' ),
|
||||
originalSize: $datas.find( '.original' ).text(),
|
||||
optimizedSize: $datas.find( '.imagify-data-item .big' ).text(),
|
||||
optimizedSize: $datas.find( '#imagify_data_sum .big' ).text(),
|
||||
saving: $datas.find( '.imagify-chart-value' ).text(),
|
||||
modalAppendTo: $this.closest( '.column-primary' ),
|
||||
trigger: $this,
|
||||
@@ -630,7 +630,7 @@
|
||||
originalUrl: originalSrc,
|
||||
optimizedUrl: $( '#imagify-full-src' ).val(),
|
||||
originalSize: $( '#imagify-original-size' ).val(),
|
||||
optimizedSize: $datas.find( '.imagify-data-item .big' ).text(),
|
||||
optimizedSize: $datas.find( '#imagify_data_sum .big' ).text(),
|
||||
saving: $datas.find( '.imagify-chart-value' ).text(),
|
||||
modalAppendTo: $( '.media-frame-content .thumbnail-image' ),
|
||||
trigger: $( '#imagify-media-frame-comparison-btn' ),
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -47,13 +47,15 @@ class Display implements SubscriberInterface {
|
||||
}
|
||||
|
||||
$enabled = isset( $values['display_nextgen'] ) ? true : false;
|
||||
$was_enabled = (bool) get_imagify_option( 'display_nextgen' );
|
||||
|
||||
$result = false;
|
||||
|
||||
if ( $enabled ) {
|
||||
// Add the AVIF file type.
|
||||
if ( $enabled && ! $was_enabled ) {
|
||||
// Add the WebP file type.
|
||||
$result = $this->get_server_conf()->add();
|
||||
} elseif ( ! $enabled ) {
|
||||
// Remove the AVIF file type.
|
||||
} elseif ( ! $enabled && $was_enabled ) {
|
||||
// Remove the WebP file type.
|
||||
$result = $this->get_server_conf()->remove();
|
||||
}
|
||||
|
||||
|
||||
@@ -173,31 +173,17 @@ class Bulk {
|
||||
'message' => 'over-quota',
|
||||
];
|
||||
}
|
||||
$formats = imagify_nextgen_images_formats();
|
||||
$media_ids = [
|
||||
'ids' => [],
|
||||
'errors' => [
|
||||
'no_file_path' => [],
|
||||
'no_backup' => [],
|
||||
],
|
||||
];
|
||||
foreach ( $formats as $format ) {
|
||||
$result = $this->get_bulk_instance( $context )->get_optimized_media_ids_without_format( $format );
|
||||
$media_ids['ids'] = array_merge( $media_ids['ids'], $result['ids'] );
|
||||
}
|
||||
$get_unoptimized_media_ids = $this->get_bulk_instance( $context )->get_unoptimized_media_ids( $optimization_level );
|
||||
|
||||
$media_ids['ids'] = array_merge( $media_ids['ids'], $get_unoptimized_media_ids );
|
||||
$media_ids = $this->get_bulk_instance( $context )->get_unoptimized_media_ids( $optimization_level );
|
||||
|
||||
if ( empty( $media_ids['ids'] ) ) {
|
||||
if ( empty( $media_ids ) ) {
|
||||
return [
|
||||
'success' => false,
|
||||
'message' => 'no-images',
|
||||
];
|
||||
}
|
||||
$media_ids['ids'] = array_unique( $media_ids['ids'] );
|
||||
|
||||
foreach ( $media_ids['ids'] as $media_id ) {
|
||||
foreach ( $media_ids as $media_id ) {
|
||||
try {
|
||||
as_enqueue_async_action(
|
||||
'imagify_optimize_media',
|
||||
@@ -597,10 +583,6 @@ class Bulk {
|
||||
* @param array $old_value The old option value.
|
||||
* @param array $value The new option value.
|
||||
*
|
||||
* Please note that the convert_to_avif new value is a checkbox,
|
||||
* so it equals 1 when it's set otherwise it's not set.
|
||||
* That's why we need to use empty function when checking its value.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function maybe_generate_missing_nextgen( $old_value, $value ) {
|
||||
@@ -609,11 +591,6 @@ class Bulk {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( empty( $value['convert_to_avif'] ) ) {
|
||||
// new value is disabled, do nothing.
|
||||
return;
|
||||
}
|
||||
|
||||
$contexts = $this->get_contexts();
|
||||
$formats = imagify_nextgen_images_formats();
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ abstract class AbstractData implements DataInterface {
|
||||
|
||||
/**
|
||||
* Get the file size of the full size file.
|
||||
* If the WebP size is available, it is used.
|
||||
* If the Nextgen size is available, it is used.
|
||||
*
|
||||
* @since 1.9
|
||||
* @access public
|
||||
@@ -289,28 +289,36 @@ abstract class AbstractData implements DataInterface {
|
||||
*
|
||||
* @param bool $human_format True to display the image human format size (1Mb).
|
||||
* @param int $decimals Precision of number of decimal places.
|
||||
* @param bool $use_webp Use the WebP size if available.
|
||||
* @param bool $use_nextgen Use the Nextgen size if available.
|
||||
* @return string|int
|
||||
*/
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_webp = true ) {
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_nextgen = true ) {
|
||||
if ( ! $this->is_valid() ) {
|
||||
return $human_format ? imagify_size_format( 0, $decimals ) : 0;
|
||||
}
|
||||
|
||||
$data = $this->get_optimization_data();
|
||||
$media = $this->get_media();
|
||||
$data = $this->get_optimization_data();
|
||||
$media = $this->get_media();
|
||||
$format = 'webp';
|
||||
|
||||
if ( $use_webp ) {
|
||||
$process_class_name = imagify_get_optimization_process_class_name( $media->get_context() );
|
||||
$webp_size_name = 'full' . constant( $process_class_name . '::WEBP_SUFFIX' );
|
||||
}
|
||||
$process_class_name = imagify_get_optimization_process_class_name( $media->get_context() );
|
||||
$nextgen_avif_size_name = 'full' . constant( $process_class_name . '::AVIF_SUFFIX' );
|
||||
$nextgen_webp_size_name = 'full' . constant( $process_class_name . '::WEBP_SUFFIX' );
|
||||
|
||||
if ( $use_webp && ! empty( $data['sizes'][ $webp_size_name ]['optimized_size'] ) ) {
|
||||
$size = (int) $data['sizes'][ $webp_size_name ]['optimized_size'];
|
||||
$size = 0;
|
||||
|
||||
if ( $use_nextgen ) {
|
||||
/**Checking for success status before size, some cases the response is false
|
||||
* because the image is already compressed, or we have a connection timed out
|
||||
* */
|
||||
$size = ! empty( $data['sizes'][ $nextgen_webp_size_name ] ) && $data['sizes'][ $nextgen_webp_size_name ]['success'] ?
|
||||
(int) $data['sizes'][ $nextgen_webp_size_name ]['optimized_size'] : 0;
|
||||
if ( ! empty( $data['sizes'][ $nextgen_avif_size_name ]['optimized_size'] ) &&
|
||||
$data['sizes'][ $nextgen_avif_size_name ] ) {
|
||||
$size = (int) $data['sizes'][ $nextgen_avif_size_name ]['optimized_size'];
|
||||
}
|
||||
} elseif ( ! empty( $data['sizes']['full']['optimized_size'] ) ) {
|
||||
$size = (int) $data['sizes']['full']['optimized_size'];
|
||||
} else {
|
||||
$size = 0;
|
||||
}
|
||||
|
||||
if ( $size ) {
|
||||
@@ -320,10 +328,13 @@ abstract class AbstractData implements DataInterface {
|
||||
// If nothing in the database, try to get the info from the file.
|
||||
$filepath = false;
|
||||
|
||||
if ( $use_webp && ! empty( $data['sizes'][ $webp_size_name ]['success'] ) ) {
|
||||
// Try with the WebP file first.
|
||||
if ( $use_nextgen ) {
|
||||
if ( ! empty( $data['sizes'][ $nextgen_avif_size_name ]['success'] ) ) {
|
||||
$format = 'avif';
|
||||
}
|
||||
// Try with the Nextgen file first.
|
||||
$filepath = $media->get_raw_fullsize_path();
|
||||
$filepath = $filepath ? imagify_path_to_webp( $filepath ) : false;
|
||||
$filepath = $filepath ? imagify_path_to_nextgen( $filepath, $format ) : false;
|
||||
|
||||
if ( ! $filepath || ! $this->filesystem->exists( $filepath ) ) {
|
||||
$filepath = false;
|
||||
@@ -331,7 +342,7 @@ abstract class AbstractData implements DataInterface {
|
||||
}
|
||||
|
||||
if ( ! $filepath ) {
|
||||
// No WebP? The full size then.
|
||||
// No Nextgen? The full size then.
|
||||
$filepath = $media->get_fullsize_path();
|
||||
}
|
||||
|
||||
@@ -418,15 +429,20 @@ abstract class AbstractData implements DataInterface {
|
||||
}
|
||||
|
||||
$process_class_name = imagify_get_optimization_process_class_name( $this->get_media()->get_context() );
|
||||
$webp_size_name = 'full' . constant( $process_class_name . '::WEBP_SUFFIX' );
|
||||
$nextgen_webp_size_name = 'full' . constant( $process_class_name . '::WEBP_SUFFIX' );
|
||||
$nextgen_avif_size_name = 'full' . constant( $process_class_name . '::AVIF_SUFFIX' );
|
||||
|
||||
$percent = $this->get_size_data( $webp_size_name, 'percent' );
|
||||
$percent = $this->get_size_data( $nextgen_avif_size_name, 'percent' );
|
||||
|
||||
// Check for webp version if avif is not found.
|
||||
if ( ! $percent ) {
|
||||
$percent = $this->get_size_data( $nextgen_webp_size_name, 'percent' );
|
||||
}
|
||||
|
||||
if ( ! $percent ) {
|
||||
$percent = $this->get_size_data( 'full', 'percent' );
|
||||
}
|
||||
|
||||
$percent = $percent ? $percent : 0;
|
||||
$percent = $percent ?: 0;
|
||||
|
||||
return round( (float) $percent, 2 );
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ interface DataInterface {
|
||||
|
||||
/**
|
||||
* Get the file size of the full size file.
|
||||
* If the WebP size is available, it is used.
|
||||
* If the Nextgen size is available, it is used.
|
||||
*
|
||||
* @since 1.9
|
||||
* @access public
|
||||
@@ -216,10 +216,10 @@ interface DataInterface {
|
||||
*
|
||||
* @param bool $human_format True to display the image human format size (1Mb).
|
||||
* @param int $decimals Precision of number of decimal places.
|
||||
* @param bool $use_webp Use the WebP size if available.
|
||||
* @param bool $use_nextgen Use the Nextgen size if available.
|
||||
* @return string|int
|
||||
*/
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_webp = true );
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_nextgen = true );
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
@@ -208,7 +208,7 @@ class Noop implements DataInterface {
|
||||
|
||||
/**
|
||||
* Get the file size of the full size file.
|
||||
* If the WebP size is available, it is used.
|
||||
* If the Nextgen size is available, it is used.
|
||||
*
|
||||
* @since 1.9
|
||||
* @access public
|
||||
@@ -216,10 +216,10 @@ class Noop implements DataInterface {
|
||||
*
|
||||
* @param bool $human_format True to display the image human format size (1Mb).
|
||||
* @param int $decimals Precision of number of decimal places.
|
||||
* @param bool $use_webp Use the WebP size if available.
|
||||
* @param bool $use_nextgen Use the Nextgen size if available.
|
||||
* @return string|int
|
||||
*/
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_webp = true ) {
|
||||
public function get_optimized_size( $human_format = true, $decimals = 2, $use_nextgen = true ) {
|
||||
return $human_format ? imagify_size_format( 0, $decimals ) : 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -948,7 +948,7 @@ abstract class AbstractProcess implements ProcessInterface {
|
||||
$media->update_dimensions();
|
||||
|
||||
// Delete the WebP version.
|
||||
$this->delete_nextgen_file( $original_path );
|
||||
$this->delete_nextgen_file( $original_path, true );
|
||||
|
||||
// Restore the thumbnails.
|
||||
$response = $this->restore_thumbnails();
|
||||
@@ -989,7 +989,7 @@ abstract class AbstractProcess implements ProcessInterface {
|
||||
* In that case we must also delete the next-gen file associated to the full size.
|
||||
*/
|
||||
$keep_full_next_gen = $media->get_raw_original_path() === $media->get_raw_fullsize_path();
|
||||
$this->delete_nextgen_files( $keep_full_next_gen );
|
||||
$this->delete_nextgen_files( $keep_full_next_gen, true );
|
||||
|
||||
// Generate new thumbnails.
|
||||
return $media->generate_thumbnails();
|
||||
|
||||
@@ -53,12 +53,14 @@ class Display implements SubscriberInterface {
|
||||
}
|
||||
|
||||
$enabled = isset( $values['display_nextgen'] ) ? true : false;
|
||||
$was_enabled = (bool) get_imagify_option( 'display_nextgen' );
|
||||
|
||||
$result = false;
|
||||
|
||||
if ( $enabled ) {
|
||||
if ( $enabled && ! $was_enabled ) {
|
||||
// Add the WebP file type.
|
||||
$result = $this->get_server_conf()->add();
|
||||
} elseif ( ! $enabled ) {
|
||||
} elseif ( ! $enabled && $was_enabled ) {
|
||||
// Remove the WebP file type.
|
||||
$result = $this->get_server_conf()->remove();
|
||||
}
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
* Plugin Name: Imagify
|
||||
* Plugin URI: https://wordpress.org/plugins/imagify/
|
||||
* Description: Dramatically reduce image file sizes without losing quality, make your website load faster, boost your SEO and save money on your bandwidth using Imagify, the new most advanced image optimization tool.
|
||||
* Version: 2.2.0.1
|
||||
* Version: 2.2.1
|
||||
* Requires at least: 5.3
|
||||
* Requires PHP: 7.0
|
||||
* Requires PHP: 7.3
|
||||
* Author: Imagify – Optimize Images & Convert WebP & Avif
|
||||
* Author URI: https://imagify.io
|
||||
* Licence: GPLv2
|
||||
@@ -19,7 +19,7 @@
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
// Imagify defines.
|
||||
define( 'IMAGIFY_VERSION', '2.2.0.1' );
|
||||
define( 'IMAGIFY_VERSION', '2.2.1' );
|
||||
define( 'IMAGIFY_SLUG', 'imagify' );
|
||||
define( 'IMAGIFY_FILE', __FILE__ );
|
||||
define( 'IMAGIFY_PATH', realpath( plugin_dir_path( IMAGIFY_FILE ) ) . '/' );
|
||||
|
||||
@@ -15,17 +15,17 @@ class WooCommerce {
|
||||
* @return void
|
||||
*/
|
||||
public function init() {
|
||||
add_action( 'woocommerce_single_product_summary', [ $this, 'variable_products_webp_compat' ] );
|
||||
add_action( 'woocommerce_single_product_summary', [ $this, 'variable_products_nextgen_compat' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add Variable Products Webp Compatibility.
|
||||
* Add Variable Products Next-gen images Compatibility.
|
||||
*
|
||||
* @since 1.10.0
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function variable_products_webp_compat() {
|
||||
public function variable_products_nextgen_compat() {
|
||||
global $product;
|
||||
|
||||
if ( ! isset( $product ) || ! $product->is_type( 'variable' ) ) {
|
||||
|
||||
@@ -6,12 +6,11 @@ defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
*/
|
||||
if ( function_exists( 'is_amp_endpoint' ) ) :
|
||||
|
||||
add_filter( 'imagify_allow_picture_tags_for_webp', 'imagify_amp_disable_picture_on_endpoint' );
|
||||
add_filter( 'imagify_allow_picture_tags_for_nextgen', 'imagify_amp_disable_picture_on_endpoint' );
|
||||
/**
|
||||
* Do not use <picture> tags in AMP pages.
|
||||
*
|
||||
* @since 1.9
|
||||
* @author Grégory Viguier
|
||||
* @since 1.9
|
||||
*
|
||||
* @param bool $allow True to allow the use of <picture> tags (default). False to prevent their use.
|
||||
* @return bool
|
||||
|
||||
@@ -5,8 +5,6 @@ use Imagify\Traits\InstanceGetterTrait;
|
||||
use Imagify_Enable_Media_Replace_Deprecated;
|
||||
use Imagify_Filesystem;
|
||||
|
||||
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' );
|
||||
|
||||
/**
|
||||
* Compat class for Enable Media Replace plugin.
|
||||
*
|
||||
@@ -40,12 +38,12 @@ class Main extends Imagify_Enable_Media_Replace_Deprecated {
|
||||
protected $old_backup_path;
|
||||
|
||||
/**
|
||||
* List of paths to the old WebP files.
|
||||
* List of paths to the old next-gen files.
|
||||
*
|
||||
* @var array
|
||||
* @since 1.9.8
|
||||
*/
|
||||
protected $old_webp_paths = [];
|
||||
protected $old_nextgen_paths = [];
|
||||
|
||||
/**
|
||||
* Launch the hooks before the files and data are replaced.
|
||||
@@ -84,29 +82,26 @@ class Main extends Imagify_Enable_Media_Replace_Deprecated {
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep track of existing WebP files.
|
||||
* Keep track of existing next-gen files.
|
||||
*
|
||||
* Whether the user chooses to rename the files or not, we will need to delete the current WebP files before creating new ones:
|
||||
* Whether the user chooses to rename the files or not, we will need to delete the current next-gen files before creating new ones:
|
||||
* - Rename the files: the old ones must be removed, they are useless now.
|
||||
* - Do not rename the files: the thumbnails may still get new names because of the suffix containing the image dimensions, which may differ (for example when thumbnails are scaled, not cropped).
|
||||
* In this last case, the thumbnails with the old dimensions are removed from the drive and from the WP’s post meta, so there is no need of keeping orphan WebP files that would stay on the drive for ever, even after the attachment is deleted from WP.
|
||||
* In this last case, the thumbnails with the old dimensions are removed from the drive and from the WP’s post meta, so there is no need of keeping orphan next-gen files that would stay on the drive for ever, even after the attachment is deleted from WP.
|
||||
*/
|
||||
foreach ( $this->process->get_media()->get_media_files() as $media_file ) {
|
||||
$this->old_webp_paths[] = imagify_path_to_webp( $media_file['path'] );
|
||||
foreach ( [ 'avif', 'webp' ] as $format ) {
|
||||
$this->old_nextgen_paths[] = imagify_path_to_nextgen( $media_file['path'], $format );
|
||||
}
|
||||
}
|
||||
|
||||
// Delete the old backup file and old WebP files.
|
||||
// Delete the old backup file and old next-gen files.
|
||||
add_action( 'imagify_before_auto_optimization', [ $this, 'delete_backup' ] );
|
||||
add_action( 'imagify_not_optimized_attachment_updated', [ $this, 'delete_backup' ] );
|
||||
}
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** HOOKS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Delete previous backup file and WebP files.
|
||||
* Delete previous backup file and next-gen files.
|
||||
* This is done after the images have been already replaced by Enable Media Replace.
|
||||
*
|
||||
* @since 1.8.4
|
||||
@@ -126,19 +121,14 @@ class Main extends Imagify_Enable_Media_Replace_Deprecated {
|
||||
$this->old_backup_path = false;
|
||||
}
|
||||
|
||||
if ( ! empty( $this->old_webp_paths ) ) {
|
||||
// Delete old WebP files.
|
||||
$this->old_webp_paths = array_filter( $this->old_webp_paths, [ $filesystem, 'exists' ] );
|
||||
array_map( [ $filesystem, 'delete' ], $this->old_webp_paths );
|
||||
$this->old_webp_paths = [];
|
||||
if ( ! empty( $this->old_nextgen_paths ) ) {
|
||||
// Delete old next-gen files.
|
||||
$this->old_nextgen_paths = array_filter( $this->old_nextgen_paths, [ $filesystem, 'exists' ] );
|
||||
array_map( [ $filesystem, 'delete' ], $this->old_nextgen_paths );
|
||||
$this->old_nextgen_paths = [];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
/** TOOLS =================================================================================== */
|
||||
/** ----------------------------------------------------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Get the optimization process corresponding to the current media.
|
||||
*
|
||||
|
||||
@@ -142,7 +142,7 @@ class NGG extends AbstractBulk {
|
||||
) );
|
||||
|
||||
$wpdb->flush();
|
||||
unset( $ngg_table, $data_table, $webp_suffix );
|
||||
unset( $ngg_table, $data_table, $suffix );
|
||||
|
||||
$data = [
|
||||
'ids' => [],
|
||||
@@ -169,7 +169,7 @@ class NGG extends AbstractBulk {
|
||||
$backup_path = get_imagify_ngg_attachment_backup_path( $file_path );
|
||||
|
||||
if ( ! $this->filesystem->exists( $backup_path ) ) {
|
||||
// No backup, no WebP.
|
||||
// No backup, no next-gen.
|
||||
$data['errors']['no_backup'][] = $file_id;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -150,74 +150,80 @@ function _imagify_ngg_media_library_imported_image_data( $image, $attachment ) {
|
||||
}
|
||||
|
||||
/**
|
||||
* WebP for the full size.
|
||||
* Next-gen for the full size.
|
||||
* Look for an existing copy locally:
|
||||
* - if it exists, copy it (and its optimization data),
|
||||
* - if not, add it to the optimization queue.
|
||||
*/
|
||||
$add_full_webp = $wp_media->is_image() && get_imagify_option( 'convert_to_webp' );
|
||||
$add_full_nextgen = $wp_media->is_image();
|
||||
|
||||
if ( $add_full_webp ) {
|
||||
// It's a supported image and WebP conversion is enabled.
|
||||
$wp_full_path_webp = false;
|
||||
$webp_size_name = 'full' . $wp_process::WEBP_SUFFIX;
|
||||
$wp_webp_data = $wp_data->get_size_data( $webp_size_name );
|
||||
if ( $add_full_nextgen ) {
|
||||
$formats = [
|
||||
'avif' => $wp_process::AVIF_SUFFIX,
|
||||
'webp' => $wp_process::WEBP_SUFFIX,
|
||||
];
|
||||
|
||||
// Get the path to the WebP image if it exists.
|
||||
$wp_full_path_webp = $wp_process->get_fullsize_file()->get_path_to_webp();
|
||||
foreach ( $formats as $extension => $suffix ) {
|
||||
$wp_full_path_nextgen = false;
|
||||
$nextgen_size_name = 'full' . $suffix;
|
||||
$wp_nextgen_data = $wp_data->get_size_data( $nextgen_size_name );
|
||||
|
||||
if ( $wp_full_path_webp && ! $filesystem->exists( $wp_full_path_webp ) ) {
|
||||
$wp_full_path_webp = false;
|
||||
}
|
||||
// Get the path to the next-gen image if it exists.
|
||||
$wp_full_path_nextgen = $wp_process->get_fullsize_file()->get_path_to_nextgen( $extension );
|
||||
|
||||
if ( $wp_full_path_webp ) {
|
||||
// We know we have a WebP version. Make sure we have the right data.
|
||||
$wp_webp_data['success'] = true;
|
||||
if ( $wp_full_path_nextgen && ! $filesystem->exists( $wp_full_path_nextgen ) ) {
|
||||
$wp_full_path_nextgen = false;
|
||||
}
|
||||
|
||||
if ( empty( $wp_webp_data['original_size'] ) ) {
|
||||
// The WebP data is missing.
|
||||
$full_size_weight = $wp_full_size_data['original_size'];
|
||||
if ( $wp_full_path_nextgen ) {
|
||||
// We know we have a next-gen version. Make sure we have the right data.
|
||||
$wp_nextgen_data['success'] = true;
|
||||
|
||||
if ( ! $full_size_weight && $wp_backup_path ) {
|
||||
// For some reason we don't have the original file weight, but we can get it from the backup file.
|
||||
$full_size_weight = $filesystem->size( $wp_backup_path );
|
||||
if ( empty( $wp_nextgen_data['original_size'] ) ) {
|
||||
// The next-gen data is missing.
|
||||
$full_size_weight = $wp_full_size_data['original_size'];
|
||||
|
||||
if ( $full_size_weight ) {
|
||||
$wp_webp_data['original_size'] = $full_size_weight;
|
||||
if ( ! $full_size_weight && $wp_backup_path ) {
|
||||
// For some reason we don't have the original file weight, but we can get it from the backup file.
|
||||
$full_size_weight = $filesystem->size( $wp_backup_path );
|
||||
|
||||
if ( $full_size_weight ) {
|
||||
$wp_nextgen_data['original_size'] = $full_size_weight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! empty( $wp_webp_data['original_size'] ) && empty( $wp_webp_data['optimized_size'] ) ) {
|
||||
// The WebP file size.
|
||||
$wp_webp_data['optimized_size'] = $filesystem->size( $wp_full_path_webp );
|
||||
}
|
||||
if ( ! empty( $wp_nextgen_data['original_size'] ) && empty( $wp_nextgen_data['optimized_size'] ) ) {
|
||||
// The next-gen file size.
|
||||
$wp_nextgen_data['optimized_size'] = $filesystem->size( $wp_full_path_nextgen );
|
||||
}
|
||||
|
||||
if ( empty( $wp_webp_data['original_size'] ) || empty( $wp_webp_data['optimized_size'] ) ) {
|
||||
// We must have both original and optimized sizes.
|
||||
$wp_webp_data = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ( $wp_full_path_webp && $wp_webp_data ) {
|
||||
// We have the file and the data.
|
||||
// Copy the file.
|
||||
$ngg_full_file = new File( $ngg_media->get_raw_fullsize_path() );
|
||||
$ngg_full_path_webp = $ngg_full_file->get_path_to_webp(); // Destination.
|
||||
|
||||
if ( $ngg_full_path_webp ) {
|
||||
$copied = $filesystem->copy( $wp_full_path_webp, $ngg_full_path_webp, true );
|
||||
|
||||
if ( $copied ) {
|
||||
// Success.
|
||||
$filesystem->chmod_file( $ngg_full_path_webp );
|
||||
$add_full_webp = false;
|
||||
if ( empty( $wp_nextgen_data['original_size'] ) || empty( $wp_nextgen_data['optimized_size'] ) ) {
|
||||
// We must have both original and optimized sizes.
|
||||
$wp_nextgen_data = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $add_full_webp ) {
|
||||
// The WebP file has been successfully copied: now, copy the data.
|
||||
$ngg_process->get_data()->update_size_optimization_data( $webp_size_name, $wp_webp_data );
|
||||
if ( $wp_full_path_nextgen && $wp_nextgen_data ) {
|
||||
// We have the file and the data.
|
||||
// Copy the file.
|
||||
$ngg_full_file = new File( $ngg_media->get_raw_fullsize_path() );
|
||||
$ngg_full_path_nextgen = $ngg_full_file->get_path_to_nextgen( $extension ); // Destination.
|
||||
|
||||
if ( $ngg_full_path_nextgen ) {
|
||||
$copied = $filesystem->copy( $wp_full_path_nextgen, $ngg_full_path_nextgen, true );
|
||||
|
||||
if ( $copied ) {
|
||||
// Success.
|
||||
$filesystem->chmod_file( $ngg_full_path_nextgen );
|
||||
$add_full_nextgen = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $add_full_nextgen ) {
|
||||
// The next-gen file has been successfully copied: now, copy the data.
|
||||
$ngg_process->get_data()->update_size_optimization_data( $nextgen_size_name, $wp_nextgen_data );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -226,9 +232,20 @@ function _imagify_ngg_media_library_imported_image_data( $image, $attachment ) {
|
||||
$sizes = $ngg_media->get_media_files();
|
||||
unset( $sizes['full'] );
|
||||
|
||||
if ( $add_full_webp ) {
|
||||
// We could not use a local WebP copy: ask for a new one.
|
||||
$sizes[ $webp_size_name ] = [];
|
||||
if ( $add_full_nextgen ) {
|
||||
// We could not use a local next-gen copy: ask for a new one.
|
||||
|
||||
$formats = imagify_nextgen_images_formats();
|
||||
|
||||
foreach ( $formats as $format ) {
|
||||
if ( 'webp' === $format ) {
|
||||
$suffix = $wp_process::WEBP_SUFFIX;
|
||||
} elseif ( 'avif' === $format ) {
|
||||
$suffix = $wp_process::AVIF_SUFFIX;
|
||||
}
|
||||
|
||||
$sizes[ 'full' . $suffix ] = [];
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $sizes ) {
|
||||
@@ -282,7 +299,7 @@ function imagify_ngg_cleanup_after_media_deletion( $image_id, $image ) {
|
||||
|
||||
/**
|
||||
* The backup file has already been deleted by NGG.
|
||||
* Delete the WebP versions and the optimization data.
|
||||
* Delete the next-gen versions and the optimization data.
|
||||
*/
|
||||
$process->delete_nextgen_files();
|
||||
|
||||
|
||||
@@ -158,19 +158,19 @@ class Main extends \Imagify_Regenerate_Thumbnails_Deprecated {
|
||||
/**
|
||||
* Optimize the sizes that have been regenerated.
|
||||
*/
|
||||
// If the media has WebP versions, recreate them for the sizes that have been regenerated.
|
||||
// If the media has next-gen versions, recreate them for the sizes that have been regenerated.
|
||||
$data = $process->get_data();
|
||||
$optimization_data = $data->get_optimization_data();
|
||||
|
||||
if ( ! empty( $optimization_data['sizes'] ) ) {
|
||||
foreach ( $optimization_data['sizes'] as $size_name => $size_data ) {
|
||||
$non_webp_size_name = $process->is_size_next_gen( $size_name );
|
||||
$non_nextgen_size_name = $process->is_size_next_gen( $size_name );
|
||||
|
||||
if ( ! $non_webp_size_name || ! isset( $sizes[ $non_webp_size_name ] ) ) {
|
||||
if ( ! $non_nextgen_size_name || ! isset( $sizes[ $non_nextgen_size_name ] ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Add the WebP size.
|
||||
// Add the next-gen size.
|
||||
$sizes[ $size_name ] = [];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,8 @@ function _imagify_attachment_submitbox_misc_actions() {
|
||||
if ( $media->has_backup() && $data->is_optimized() ) {
|
||||
?>
|
||||
<input id="imagify-full-original" type="hidden" value="<?php echo esc_url( $media->get_backup_url() ); ?>">
|
||||
<input id="imagify-full-original-size" type="hidden" value="<?php echo esc_attr( $data->get_original_size( true, 0 ) ); ?>">
|
||||
<input id="imagify-full-original-size" type="hidden" value="<?php echo esc_attr( $data->get_original_size() ); ?>">
|
||||
<input id="imagify-full-optimized-size" type="hidden" value="<?php echo esc_attr( $data->get_optimized_size() ); ?>">
|
||||
<?php
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ function get_imagify_attachment_optimization_text( $process ) {
|
||||
|
||||
$is_media_page = Imagify_Views::get_instance()->is_media_page();
|
||||
$is_library_page = Imagify_Views::get_instance()->is_wp_library_page();
|
||||
$output = $is_media_page ? '' : '<ul class="imagify-datas-list">';
|
||||
$output = $is_media_page ? '' : '<ul class="imagify-datas-list" id="imagify_data_sum">';
|
||||
$output_before = $is_media_page ? '' : '<li class="imagify-data-item">';
|
||||
$output_after = $is_media_page ? '<br/>' : '</li>';
|
||||
$reoptimize_link = get_imagify_attachment_reoptimize_link( $process );
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
=== Imagify – Optimize Images & Convert WebP & AVIF | Compress Images Easily ===
|
||||
Contributors: wp_rocket, imagify
|
||||
Tags: optimize images, convert webp, webp converter, convert AVIF, webp to AVIF, AVIF plugin, AVIF converter, image optimization, compress images, image compressor, resize images, reduce image size, performance, image optimizer, core web vitals, best image optimization plugin
|
||||
Tested up to: 6.4
|
||||
Stable tag: 2.2.0.1
|
||||
Tested up to: 6.5
|
||||
Stable tag: 2.2.1
|
||||
Requires PHP: 7.3
|
||||
License: GPLv2 or later
|
||||
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
|
||||
@@ -261,6 +262,17 @@ You can report any security bugs found in the source code of the site-reviews pl
|
||||
4. Other Media Page
|
||||
|
||||
== Changelog ==
|
||||
= 2.2.1 =
|
||||
- Enhancement: Prevent updating .htaccess when switching between AVIF and WEBP generation features
|
||||
- Enhancement: Display the smallest size of the image in the Media Library image details section
|
||||
- Enhancement: Correctly delete all Next-Gen versions when restoring the Original Image
|
||||
- Enhancement: Bump minimum version to PHP7.3
|
||||
- Bugfix: Fix the problem with progress bar when disabling AVIF generation
|
||||
- Bugfix: Fix a bug when number of images in the Bulk Optimization section was not correct
|
||||
- Bugfix: Fix the original/optimized image comparision bug
|
||||
- 3rd-party compatibility: Update compatibility with Next-Gen Gallery to match AVIF images
|
||||
- 3rd-party compatibility: Update compatibility with AMP, Regenerate Thumbnails and WooCommerce to work correctly with AVIF images
|
||||
|
||||
= 2.2.0.1 =
|
||||
- Bugfix: Preserve "Display images in webp format" configuration when updating.
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<?php return array(
|
||||
'root' => array(
|
||||
'name' => 'wp-media/imagify-plugin',
|
||||
'pretty_version' => 'v2.2.0.1',
|
||||
'version' => '2.2.0.1',
|
||||
'reference' => '910f12a51e611f67e7f68302f8ff1099c6ae3590',
|
||||
'pretty_version' => 'v2.2.1',
|
||||
'version' => '2.2.1.0',
|
||||
'reference' => '4f51e4e733650db2daf440926fa9ff911bc1da27',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
@@ -29,9 +29,9 @@
|
||||
'dev_requirement' => false,
|
||||
),
|
||||
'wp-media/imagify-plugin' => array(
|
||||
'pretty_version' => 'v2.2.0.1',
|
||||
'version' => '2.2.0.1',
|
||||
'reference' => '910f12a51e611f67e7f68302f8ff1099c6ae3590',
|
||||
'pretty_version' => 'v2.2.1',
|
||||
'version' => '2.2.1.0',
|
||||
'reference' => '4f51e4e733650db2daf440926fa9ff911bc1da27',
|
||||
'type' => 'wordpress-plugin',
|
||||
'install_path' => __DIR__ . '/../../',
|
||||
'aliases' => array(),
|
||||
|
||||
Reference in New Issue
Block a user