Edit File by line

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /home/sportsfever/public_html/filemanger/function.php on line 93
/home/sportsfe.../httpdocs/wp-conte.../plugins/wp-smush.../core/integrat.../nextgen
File: class-thumbs.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Extend NextGen Mixin class to smush dynamic images.
[2] Fix | Delete
*
[3] Fix | Delete
* @package Smush\Core\Integrations\NextGen
[4] Fix | Delete
*/
[5] Fix | Delete
[6] Fix | Delete
namespace Smush\Core\Integrations\NextGen;
[7] Fix | Delete
[8] Fix | Delete
use C_Component_Registry;
[9] Fix | Delete
use C_Gallery_Storage;
[10] Fix | Delete
use C_Image;
[11] Fix | Delete
use Mixin;
[12] Fix | Delete
use nggdb;
[13] Fix | Delete
use WP_Smush;
[14] Fix | Delete
[15] Fix | Delete
if ( ! defined( 'WPINC' ) ) {
[16] Fix | Delete
die;
[17] Fix | Delete
}
[18] Fix | Delete
[19] Fix | Delete
/**
[20] Fix | Delete
* Class Thumbs
[21] Fix | Delete
*/
[22] Fix | Delete
class Thumbs extends Mixin {
[23] Fix | Delete
/**
[24] Fix | Delete
* Overrides the NextGen Gallery function, to smush the dynamic images and thumbnails created by gallery
[25] Fix | Delete
*
[26] Fix | Delete
* @param int|object|C_Image $image Image object.
[27] Fix | Delete
* @param string $size Size.
[28] Fix | Delete
* @param array|null $params Optional. Parameters array.
[29] Fix | Delete
* @param bool $skip_defaults Optional. Skip defaults.
[30] Fix | Delete
*
[31] Fix | Delete
* @return bool|object
[32] Fix | Delete
*/
[33] Fix | Delete
function generate_image_size( $image, $size, $params = null, $skip_defaults = false ) {
[34] Fix | Delete
$smush = WP_Smush::get_instance()->core()->mod->smush;
[35] Fix | Delete
[36] Fix | Delete
$image_id = ! empty( $image->pid ) ? $image->pid : '';
[37] Fix | Delete
// Get image from storage object if we don't have it already.
[38] Fix | Delete
if ( empty( $image_id ) ) {
[39] Fix | Delete
// Get metadata For the image.
[40] Fix | Delete
// Registry Object for NextGen Gallery.
[41] Fix | Delete
$registry = C_Component_Registry::get_instance();
[42] Fix | Delete
[43] Fix | Delete
/**
[44] Fix | Delete
* Gallery Storage Object.
[45] Fix | Delete
*
[46] Fix | Delete
* @var C_Gallery_Storage $storage
[47] Fix | Delete
*/
[48] Fix | Delete
$storage = $registry->get_utility( 'I_Gallery_Storage' );
[49] Fix | Delete
[50] Fix | Delete
$image_id = $storage->object->_get_image_id( $image );
[51] Fix | Delete
}
[52] Fix | Delete
// Call the actual function to generate the image, and pass the image to smush.
[53] Fix | Delete
$success = $this->call_parent( 'generate_image_size', $image, $size, $params, $skip_defaults );
[54] Fix | Delete
if ( $success ) {
[55] Fix | Delete
$filename = $success->fileName;
[56] Fix | Delete
// Smush it, if it exists.
[57] Fix | Delete
if ( file_exists( $filename ) ) {
[58] Fix | Delete
$response = $smush->do_smushit( $filename );
[59] Fix | Delete
[60] Fix | Delete
// If the image was smushed.
[61] Fix | Delete
if ( ! is_wp_error( $response ) && ! empty( $response['data'] ) && $response['data']->bytes_saved > 0 ) {
[62] Fix | Delete
// Check for existing stats.
[63] Fix | Delete
if ( ! empty( $image->meta_data ) && ! empty( $image->meta_data['wp_smush'] ) ) {
[64] Fix | Delete
$stats = $image->meta_data['wp_smush'];
[65] Fix | Delete
} else {
[66] Fix | Delete
// Initialize stats array.
[67] Fix | Delete
$stats = array(
[68] Fix | Delete
'stats' => array_merge(
[69] Fix | Delete
$smush->get_size_signature(),
[70] Fix | Delete
array(
[71] Fix | Delete
'api_version' => - 1,
[72] Fix | Delete
'lossy' => - 1,
[73] Fix | Delete
'keep_exif' => false,
[74] Fix | Delete
)
[75] Fix | Delete
),
[76] Fix | Delete
'sizes' => array(),
[77] Fix | Delete
);
[78] Fix | Delete
[79] Fix | Delete
$stats['bytes'] = $response['data']->bytes_saved;
[80] Fix | Delete
$stats['percent'] = $response['data']->compression;
[81] Fix | Delete
$stats['size_after'] = $response['data']->after_size;
[82] Fix | Delete
$stats['size_before'] = $response['data']->before_size;
[83] Fix | Delete
$stats['time'] = $response['data']->time;
[84] Fix | Delete
}
[85] Fix | Delete
$stats['sizes'][ $size ] = (object) $smush->array_fill_placeholders( $smush->get_size_signature(), (array) $response['data'] );
[86] Fix | Delete
[87] Fix | Delete
if ( isset( $image->metadata ) ) {
[88] Fix | Delete
$image->meta_data['wp_smush'] = $stats;
[89] Fix | Delete
nggdb::update_image_meta( $image->pid, $image->meta_data );
[90] Fix | Delete
}
[91] Fix | Delete
[92] Fix | Delete
// Allows To get the stats for each image, after the image is smushed.
[93] Fix | Delete
do_action( 'wp_smush_nextgen_image_stats', $image_id, $stats );
[94] Fix | Delete
}
[95] Fix | Delete
}
[96] Fix | Delete
}
[97] Fix | Delete
return $success;
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function