<span class="product-item-image-original" id="<?=$itemIds['PICT']?>" style="background-image: url(' <?
$renderImage = CFile::ResizeImageGet($item['PREVIEW_PICTURE']['ID'], Array("width" => 65, "height" => 57), BX_RESIZE_IMAGE_EXACT, false); echo ''.$renderImage["src"].'';
?>'); <?=($showSlider ? 'display: none;' : '')?>"></span>
BX.adjust(this.obPict, {style: {backgroundImage: 'url(\'' + this.offers[index].PREVIEW_PICTURE.SRC + '\')'}});
BX.adjust(this.obPict, {style: {backgroundImage: 'url(\'' + this.offers[index].PREVIEW_PICTURE.SRC + '\')'}});
this.obPictSlider.appendChild(
BX.create('SPAN', {
props: {className: 'product-item-image-slide item' + (i == 0 ? ' active' : '')},
style: {backgroundImage: 'url(\'' + this.offers[index].MORE_PHOTO[i].SRC + '\')'}
})
);
AddEventHandler("iblock", "OnAfterIBlockElementAdd", "resizePropertyFilePhoto");
AddEventHandler("iblock", "OnAfterIBlockElementUpdate", "resizePropertyFilePhoto");
function resizePropertyFilePhoto($arFields){
global $APPLICATION;
CModule::IncludeModule('iblock');
switch ($arFields["IBLOCK_ID"]){
case 15:
$IBLOCK_ID = 15;
$PROPERTY_CODE = "ATTR_FOTOMORE";
$MaxWidth = 1920;
$MaxHeight = 1080;
break;
case 18:
$IBLOCK_ID = 18;
$PROPERTY_CODE = "ATTR_FILES";
$MaxWidth = 1920;
$MaxHeight = 1080;
break;
default:
$IBLOCK_ID = 0;
}
if($IBLOCK_ID !== 0) {
$new_files = array();
$old_files = array();
$res = CIBlockElement::GetProperty($arFields["IBLOCK_ID"], $arFields["ID"], "sort", "asc", array("CODE" => $PROPERTY_CODE));
while ($ob = $res->GetNext()) {
$file_path = CFile::GetPath($ob['VALUE']);
if($file_path) {
$file_size = getimagesize($_SERVER["DOCUMENT_ROOT"].$file_path);
if (($file_size[0] > $MaxWidth) || ($file_size[1] > $MaxHeight)) {
$file = CFile::ResizeImageGet($ob['VALUE'], array(
'width'=>$MaxWidth,
'height'=>$MaxHeight
), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true);
$new_files[] = array(
"VALUE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].$file["src"]),
"DESCRIPTION" => $ob['DESCRIPTION']);
} else {
$new_files[] = array(
"VALUE" => CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"].$file_path),
"DESCRIPTION" => $ob['DESCRIPTION']);
}
$old_files[] = $ob['VALUE'];
}
}
if(count($new_files) > 0) {
$PROPERTY_VALUE = $new_files;
CIBlockElement::SetPropertyValuesEx($arFields["ID"], $arFields["IBLOCK_ID"], array($PROPERTY_CODE => $PROPERTY_VALUE));
foreach ($old_files as $key=>$val) {
CFile::Delete($val);
}
}
unset($new_files);
unset($old_files);
}
}