<?php
$rootPath = strval($_SERVER['DOCUMENT_ROOT']);
$filePath = strval($modx->getOption('filePath', $scriptProperties, false));
$file = $rootPath .'/'. $filePath;
if($file) {
$fileExt = pathinfo($file, PATHINFO_EXTENSION);
$fileSize = filesize(strval($file));
if($fileSize > 1024){
$fileSize = ($fileSize/1024);
if($fileSize > 1024){
$fileSize = ($fileSize/1024);
if($fileSize > 1024) {
$fileSize = ($fileSize/1024);
$fileSize = round($fileSize, 1);
return "." . $fileExt ." (". $fileSize ." GB)";
} else {
$fileSize = round($fileSize, 1);
return "." . $fileExt ." (". $fileSize ." MB)";
}
} else {
$fileSize = round($fileSize, 1);
return "." . $fileExt ." (". $fileSize ." KB)";
}
} else {
$fileSize = round($fileSize, 1);
return "." . $fileExt ." (". $fileSize ." B)";
}
}
<p>Размер файла - [[!fileInfo?file=`[[++assets_path]]tpl/css/style.css`]]</p>
[[+file:reverse:limit=`3`:reverse:is=`pdf`:then=`<img src="/img1.png">`:else=`<img src="/img2.png">`]]