| Server IP : 38.190.208.107 / Your IP : 216.73.217.46 Web Server : nginx/1.28.1 System : Linux ht2026040333114 6.1.0-10-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.37-1 (2023-07-03) x86_64 User : root ( 0) PHP Version : 8.2.28 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv,eval,assert,passthru,system,exec,shell_exec,popen,proc_open MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/wp.12/wp-content/plugins/ewww-image-optimizer/classes/ |
Upload File : |
<?php
/**
* Class and methods to integrate with the WP_Image_Editor_Gmagick class and other extensions.
*
* @link https://ewww.io
* @package EWWW_Image_Optimizer
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( class_exists( 'WP_Image_Editor_Gmagick' ) ) {
/**
* Extension of the WP_Image_Editor_Gmagick class to auto-compress edited images.
*
* @see WP_Image_Editor_Gmagick
*/
class EWWWIO_Gmagick_Editor extends WP_Image_Editor_Gmagick {
/**
* Saves a file from the image editor.
*
* @param resource $image A Gmagick image object.
* @param string $filename Optional. The name of the file to be saved to.
* @param string $mime_type Optional. The mimetype of the file.
* @return WP_Error| array The full path, base filename, width, height, and mimetype.
*/
protected function _save( $image, $filename = null, $mime_type = null ) {
global $ewww_preempt_editor;
if ( ! empty( $ewww_preempt_editor ) || ! defined( 'EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR' ) || ! EWWW_IMAGE_OPTIMIZER_ENABLE_EDITOR ) {
return parent::_save( $image, $filename, $mime_type );
}
list( $filename, $extension, $mime_type ) = $this->get_output_format( $filename, $mime_type );
if ( ! $filename ) {
$filename = $this->generate_filename( null, null, $extension );
}
if ( apply_filters( 'ewwwio_editor_prevent_overwrite', true ) && ewwwio_is_file( $filename ) ) {
ewwwio_debug_message( "detected existing file: $filename" );
$current_size = wp_getimagesize( $filename );
if ( $current_size && (int) $this->size['width'] === (int) $current_size[0] && (int) $this->size['height'] === (int) $current_size[1] ) {
ewwwio_debug_message( "existing file has same dimensions, not saving $filename" );
return array(
'path' => $filename,
'file' => wp_basename( apply_filters( 'image_make_intermediate_size', $filename ) ),
'width' => $this->size['width'],
'height' => $this->size['height'],
'mime-type' => $mime_type,
);
}
}
$saved = parent::_save( $image, $filename, $mime_type );
if ( ! is_wp_error( $saved ) ) {
if ( ! $filename ) {
$filename = $saved['path'];
}
if ( file_exists( $filename ) ) {
ewww_image_optimizer( $filename );
ewwwio_debug_message( "image editor (gmagick) saved: $filename" );
$image_size = ewww_image_optimizer_filesize( $filename );
ewwwio_debug_message( "image editor size: $image_size" );
}
}
ewwwio_memory( __FUNCTION__ );
return $saved;
}
}
} // End if().