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-file-.../lib/php/plugins/AutoResi...
File: plugin.php
<?php
[0] Fix | Delete
[1] Fix | Delete
/**
[2] Fix | Delete
* elFinder Plugin AutoResize
[3] Fix | Delete
* Auto resize on file upload.
[4] Fix | Delete
* ex. binding, configure on connector options
[5] Fix | Delete
* $opts = array(
[6] Fix | Delete
* 'bind' => array(
[7] Fix | Delete
* 'upload.presave' => array(
[8] Fix | Delete
* 'Plugin.AutoResize.onUpLoadPreSave'
[9] Fix | Delete
* )
[10] Fix | Delete
* ),
[11] Fix | Delete
* // global configure (optional)
[12] Fix | Delete
* 'plugin' => array(
[13] Fix | Delete
* 'AutoResize' => array(
[14] Fix | Delete
* 'enable' => true, // For control by volume driver
[15] Fix | Delete
* 'maxWidth' => 1024, // Path to Water mark image
[16] Fix | Delete
* 'maxHeight' => 1024, // Margin right pixel
[17] Fix | Delete
* 'quality' => 95, // JPEG image save quality
[18] Fix | Delete
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
[19] Fix | Delete
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
[20] Fix | Delete
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
[21] Fix | Delete
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
[22] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[23] Fix | Delete
* // In case of using any key, specify it as an array
[24] Fix | Delete
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
[25] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[26] Fix | Delete
* // In case of using any key, specify it as an array
[27] Fix | Delete
* )
[28] Fix | Delete
* ),
[29] Fix | Delete
* // each volume configure (optional)
[30] Fix | Delete
* 'roots' => array(
[31] Fix | Delete
* array(
[32] Fix | Delete
* 'driver' => 'LocalFileSystem',
[33] Fix | Delete
* 'path' => '/path/to/files/',
[34] Fix | Delete
* 'URL' => 'http://localhost/to/files/'
[35] Fix | Delete
* 'plugin' => array(
[36] Fix | Delete
* 'AutoResize' => array(
[37] Fix | Delete
* 'enable' => true, // For control by volume driver
[38] Fix | Delete
* 'maxWidth' => 1024, // Path to Water mark image
[39] Fix | Delete
* 'maxHeight' => 1024, // Margin right pixel
[40] Fix | Delete
* 'quality' => 95, // JPEG image save quality
[41] Fix | Delete
* 'preserveExif' => false, // Preserve EXIF data (Imagick only)
[42] Fix | Delete
* 'forceEffect' => false, // For change quality or make progressive JPEG of small images
[43] Fix | Delete
* 'targetType' => IMG_GIF|IMG_JPG|IMG_PNG|IMG_WBMP, // Target image formats ( bit-field )
[44] Fix | Delete
* 'offDropWith' => null, // Enabled by default. To disable it if it is dropped with pressing the meta key
[45] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[46] Fix | Delete
* // In case of using any key, specify it as an array
[47] Fix | Delete
* 'onDropWith' => null // Disabled by default. To enable it if it is dropped with pressing the meta key
[48] Fix | Delete
* // Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[49] Fix | Delete
* // In case of using any key, specify it as an array
[50] Fix | Delete
* )
[51] Fix | Delete
* )
[52] Fix | Delete
* )
[53] Fix | Delete
* )
[54] Fix | Delete
* );
[55] Fix | Delete
*
[56] Fix | Delete
* @package elfinder
[57] Fix | Delete
* @author Naoki Sawada
[58] Fix | Delete
* @license New BSD
[59] Fix | Delete
*/
[60] Fix | Delete
class elFinderPluginAutoResize extends elFinderPlugin
[61] Fix | Delete
{
[62] Fix | Delete
[63] Fix | Delete
public function __construct($opts)
[64] Fix | Delete
{
[65] Fix | Delete
$defaults = array(
[66] Fix | Delete
'enable' => true, // For control by volume driver
[67] Fix | Delete
'maxWidth' => 1024, // Path to Water mark image
[68] Fix | Delete
'maxHeight' => 1024, // Margin right pixel
[69] Fix | Delete
'quality' => 95, // JPEG image save quality
[70] Fix | Delete
'preserveExif' => false, // Preserve EXIF data (Imagick only)
[71] Fix | Delete
'forceEffect' => false, // For change quality or make progressive JPEG of small images
[72] Fix | Delete
'targetType' => IMG_GIF | IMG_JPG | IMG_PNG | IMG_WBMP, // Target image formats ( bit-field )
[73] Fix | Delete
'offDropWith' => null, // To disable it if it is dropped with pressing the meta key
[74] Fix | Delete
// Alt: 8, Ctrl: 4, Meta: 2, Shift: 1 - sum of each value
[75] Fix | Delete
// In case of using any key, specify it as an array
[76] Fix | Delete
'disableWithContentSaveId' => true // Disable on URL upload with post data "contentSaveId"
[77] Fix | Delete
);
[78] Fix | Delete
[79] Fix | Delete
$this->opts = array_merge($defaults, $opts);
[80] Fix | Delete
[81] Fix | Delete
}
[82] Fix | Delete
[83] Fix | Delete
public function onUpLoadPreSave(&$thash, &$name, $src, $elfinder, $volume)
[84] Fix | Delete
{
[85] Fix | Delete
if (!$src) {
[86] Fix | Delete
return false;
[87] Fix | Delete
}
[88] Fix | Delete
[89] Fix | Delete
$opts = $this->getCurrentOpts($volume);
[90] Fix | Delete
[91] Fix | Delete
if (!$this->iaEnabled($opts, $elfinder)) {
[92] Fix | Delete
return false;
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
$imageType = null;
[96] Fix | Delete
$srcImgInfo = null;
[97] Fix | Delete
if (extension_loaded('fileinfo') && function_exists('mime_content_type')) {
[98] Fix | Delete
$mime = mime_content_type($src);
[99] Fix | Delete
if (substr($mime, 0, 5) !== 'image') {
[100] Fix | Delete
return false;
[101] Fix | Delete
}
[102] Fix | Delete
}
[103] Fix | Delete
if (extension_loaded('exif') && function_exists('exif_imagetype')) {
[104] Fix | Delete
$imageType = exif_imagetype($src);
[105] Fix | Delete
if ($imageType === false) {
[106] Fix | Delete
return false;
[107] Fix | Delete
}
[108] Fix | Delete
} else {
[109] Fix | Delete
$srcImgInfo = getimagesize($src);
[110] Fix | Delete
if ($srcImgInfo === false) {
[111] Fix | Delete
return false;
[112] Fix | Delete
}
[113] Fix | Delete
$imageType = $srcImgInfo[2];
[114] Fix | Delete
}
[115] Fix | Delete
[116] Fix | Delete
// check target image type
[117] Fix | Delete
$imgTypes = array(
[118] Fix | Delete
IMAGETYPE_GIF => IMG_GIF,
[119] Fix | Delete
IMAGETYPE_JPEG => IMG_JPEG,
[120] Fix | Delete
IMAGETYPE_PNG => IMG_PNG,
[121] Fix | Delete
IMAGETYPE_BMP => IMG_WBMP,
[122] Fix | Delete
IMAGETYPE_WBMP => IMG_WBMP
[123] Fix | Delete
);
[124] Fix | Delete
if (!isset($imgTypes[$imageType]) || !($opts['targetType'] & $imgTypes[$imageType])) {
[125] Fix | Delete
return false;
[126] Fix | Delete
}
[127] Fix | Delete
[128] Fix | Delete
if (!$srcImgInfo) {
[129] Fix | Delete
$srcImgInfo = getimagesize($src);
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
if ($opts['forceEffect'] || $srcImgInfo[0] > $opts['maxWidth'] || $srcImgInfo[1] > $opts['maxHeight']) {
[133] Fix | Delete
return $this->resize($volume, $src, $srcImgInfo, $opts['maxWidth'], $opts['maxHeight'], $opts['quality'], $opts['preserveExif']);
[134] Fix | Delete
}
[135] Fix | Delete
[136] Fix | Delete
return false;
[137] Fix | Delete
}
[138] Fix | Delete
[139] Fix | Delete
private function resize($volume, $src, $srcImgInfo, $maxWidth, $maxHeight, $jpgQuality, $preserveExif)
[140] Fix | Delete
{
[141] Fix | Delete
$zoom = min(($maxWidth / $srcImgInfo[0]), ($maxHeight / $srcImgInfo[1]));
[142] Fix | Delete
$width = round($srcImgInfo[0] * $zoom);
[143] Fix | Delete
$height = round($srcImgInfo[1] * $zoom);
[144] Fix | Delete
$unenlarge = true;
[145] Fix | Delete
$checkAnimated = true;
[146] Fix | Delete
[147] Fix | Delete
return $volume->imageUtil('resize', $src, compact('width', 'height', 'jpgQuality', 'preserveExif', 'unenlarge', 'checkAnimated'));
[148] Fix | Delete
}
[149] Fix | Delete
}
[150] Fix | Delete
[151] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function