You've already forked EasyImages2.0
mirror of
https://github.com/icret/EasyImages2.0.git
synced 2025-12-13 11:43:58 +08:00
v2.6.1
This commit is contained in:
@@ -41,7 +41,9 @@ if ($handle->uploaded) {
|
||||
// 允许上传的mime类型
|
||||
$handle->allowed = array('image/*');
|
||||
// 文件命名
|
||||
$handle->file_new_name_body = imgName($handle->file_src_name_body) . '-' . $tokenID;
|
||||
$handle->file_new_name_body = imgName($handle->file_src_name_body);
|
||||
// 添加Token ID
|
||||
$handle->file_name_body_add = '-' . $tokenID;
|
||||
// 最大上传限制
|
||||
$handle->file_max_sizes = $config['maxSize'];
|
||||
// 最大宽度
|
||||
@@ -53,25 +55,64 @@ if ($handle->uploaded) {
|
||||
// 最小高度
|
||||
$handle->image_min_height = $config['minHeight'];
|
||||
// 转换图片为指定格式
|
||||
if (isset($config['imgConvert'])) {
|
||||
if ($config['imgConvert']) {
|
||||
// 只转换非webp格式和非动态图片
|
||||
if ($handle->file_src_name_ext !== 'webp' && !isAnimatedGif($handle->file_src_pathname)) {
|
||||
$handle->image_convert = $config['imgConvert'];
|
||||
// PNG 图像的压缩级别,介于 1(快速但大文件)和 9(慢但较小文件)之间
|
||||
$handle->png_compression = 9 - round($config['compress_ratio'] / 11.2);
|
||||
// WEBP 图像的压缩质量 1-100
|
||||
$handle->webp_quality = $config['compress_ratio'];
|
||||
// JPEG 图像的压缩质量 1-100
|
||||
$handle->jpeg_quality = $config['compress_ratio'];
|
||||
}
|
||||
}
|
||||
|
||||
/* 等比例缩减图片 放到前端了*/
|
||||
/*
|
||||
if ($config['imgRatio']) {
|
||||
$handle->image_resize = true;
|
||||
$handle->image_x = $config['image_x'];
|
||||
$handle->image_y = $config['image_y'];
|
||||
// 如果调整后的图像大于原始图像,则取消调整大小,以防止放大
|
||||
$handle->image_no_enlarging = true;
|
||||
}
|
||||
*/
|
||||
|
||||
// 默认目录
|
||||
$Img_path = config_path();
|
||||
|
||||
if ($config['token_path_status'] == 1) {
|
||||
$Img_path = config_path($tokenID . date('/Y/m/d/'));
|
||||
}
|
||||
|
||||
// 存储图片路径:images/201807/
|
||||
$handle->process('../' . config_path());
|
||||
$handle->process(APP_ROOT . $Img_path);
|
||||
|
||||
// 图片完整相对路径:/i/2021/05/03/k88e7p.jpg
|
||||
if ($handle->processed) {
|
||||
header('Content-type:text/json');
|
||||
// 上传成功后返回json数据
|
||||
$pathIMG = config_path() . $handle->file_dst_name;
|
||||
$imageUrl = $config['imgurl'] . $pathIMG;
|
||||
$pathIMG = $Img_path . $handle->file_dst_name;
|
||||
$imageUrl = rand_imgurl() . $pathIMG;
|
||||
|
||||
// 原图保护 key值是由crc32加密的hide_key
|
||||
$hide_original = $config['hide'] == 1 ? $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl;
|
||||
// $hide_original = $config['hide'] == 1 ? $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key'])) : $imageUrl;
|
||||
|
||||
/**
|
||||
* 以下为控制开启源图保护或者返回值隐藏config文件中的path目录所更改
|
||||
* 2022年5月1日
|
||||
*/
|
||||
|
||||
// 隐藏config文件中的path目录,需要搭配网站设置
|
||||
if ($config['hide_path'] == 1) {
|
||||
$imageUrl = str_replace($config['path'], '/', $imageUrl);
|
||||
}
|
||||
|
||||
// 源图保护 key值是由crc32加密的hide_key
|
||||
if ($config['hide'] == 1) {
|
||||
$imageUrl = $config['domain'] . '/application/hide.php?key=' . urlHash($pathIMG, 0, crc32($config['hide_key']));
|
||||
}
|
||||
|
||||
// 关闭上传后显示加密删除链接
|
||||
if ($config['show_user_hash_del']) {
|
||||
|
||||
Reference in New Issue
Block a user