Created
July 14, 2021 05:28
-
-
Save dnikonov/e759d7a2a3ccc1c022589b9e185dc08c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ресайз загружаемых изображений | |
if (!function_exists('resizeUploadedImage')) { | |
/** | |
* resizeUploadedImage уменьшение изображения | |
* @param [file] $file временный файл | |
*/ | |
function resizeUploadedImage(&$file, $w=2000, $h=2000){ | |
if (!empty($file["name"])) { | |
list($width, $height) = getimagesize($file["tmp_name"]); | |
if ($width > $w || $height > $h) { | |
CFile::ResizeImage($file, array("width" => $w, "height" => $h), BX_RESIZE_IMAGE_PROPORTIONAL_ALT); | |
} | |
} elseif (!empty($file["VALUE"]["name"])) { | |
list($width, $height) = getimagesize($file["VALUE"]["tmp_name"]); | |
if ($width > $w || $height > $h) { | |
CFile::ResizeImage($file["VALUE"], array("width" => $w, "height" => $h), BX_RESIZE_IMAGE_PROPORTIONAL_ALT); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment