|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
AddEventHandler("main", "OnFileDelete", "MyOnFileDelete"); function MyOnFileDelete($arFile) { $src = $arFile["SRC"]; $curExtansion = pathinfo($_SERVER["DOCUMENT_ROOT"] . $src, PATHINFO_EXTENSION); if (strtolower($curExtansion) == "png") { $supportedExtensions = array(".jpg", ".jpeg"); foreach ($supportedExtensions as $extension) { $filePath = preg_replace('/\.png$/', $extension, $src); $filePath = $_SERVER['DOCUMENT_ROOT'].$filePath; if (file_exists($filePath)) { unlink($filePath); } } } } |
