Last active
May 5, 2019 22:24
-
-
Save di7spider/1f4320c5e29681f72737b6508b7e06a2 to your computer and use it in GitHub Desktop.
1C Bitrix (Google PageSpeed) :: CFile::ResizeImageGet + optipng + jpegtran
This file contains hidden or 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
<?php | |
$em = \Bitrix\Main\EventManager::getInstance(); | |
$em->addEventHandler("main", "OnAfterResizeImage", function ($file, $options, &$cacheImageFile, &$cacheImageFileTmp, &$arImageSize){ | |
$path = escapeshellarg($arImageSize); | |
if( !empty($path) ){ | |
try{ | |
if($file['CONTENT_TYPE'] == 'image/png'){ | |
exec('/usr/bin/optipng -o7 -strip all '.$path); | |
}else if($file['CONTENT_TYPE'] == 'image/jpeg'){ | |
exec('/usr/bin/jpegtran -copy none -optimize -outfile '.$path.' '.$path); | |
} | |
}catch (\Exception $e){} | |
} | |
}); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
параметра $callbackData не хватает