<? if (!defined('B_PROLOG_INCLUDED') || B_PROLOG_INCLUDED !== true) die();

if (!empty($arResult["DETAIL_PICTURE"]["SRC"])) {
  $arResult["PICTURE"] = $arResult["DETAIL_PICTURE"]["SRC"];
}

if (!empty($arResult["DISPLAY_PROPERTIES"]["DATE"]["VALUE"])) {
  $arResult["DATE"] = CIBlockFormatProperties::DateFormat($arParams["ACTIVE_DATE_FORMAT"], MakeTimeStamp($arResult["DISPLAY_PROPERTIES"]["DATE"]["VALUE"], CSite::GetDateFormat()));
}


//другие новости
$arResult['OTHERS']=[];
$arFilter = Array(
    "IBLOCK_ID"=>$arParams['IBLOCK_ID'],
    "ACTIVE"=>"Y",
    "!ID"=>$arResult['ID']

);
$res = CIBlockElement::GetList(Array("PROPERTY_DATE"=>"DESC"), $arFilter, false, array('nTopCount'=>3), $arSelect);
while($ob = $res->GetNextElement()) {
    $arItem = $ob->GetFields();
    $arItem['PREVIEW_PICTURE']= CFile::GetFileArray($arItem['PREVIEW_PICTURE']);
    $arItem['PROPERTIES'] = $ob->GetProperties();
    $arResult['OTHERS'][]=$arItem;




}

// фотогалерея



if ((!empty($arResult['PROPERTIES']['PHOTOS']['VALUE'])) && (str_contains($arResult['DETAIL_TEXT'], 'PHOTOGALLERY'))) {

    $photocontent='<div class="article__image-col article__image-col--50-50">
    <div class="article__image-col-wrap swiper" data-content-image-slider="container">
        <div class="article__swiper-wrapper swiper-wrapper">';

    foreach ($arResult['PROPERTIES']['PHOTOS']['VALUE'] as $k=>$item) {
        if ($k>1) break;
        $arSelect = array("ID", "IBLOCK_ID", "NAME","PREVIEW_PICTURE","PROPERTY_IMG_1921","PROPERTY_IMG", "PROPERTY_IMG_768", "PROPERTY_IMG_767");
        $arFilter = array("IBLOCK_ID" => $iblockId, "ID" => $item);
        $res = CIBlockElement::GetList(array("SORT"=>"ASC"), $arFilter, false, false, $arSelect);
        while ($ob = $res->GetNextElement()) {
            $arFields = $ob->GetFields();
            $img=CFile::GetPath($arFields['PROPERTY_IMG_VALUE']);
            $img1921=CFile::GetPath($arFields['PROPERTY_IMG_1921_VALUE']);
            $img768=CFile::GetPath($arFields['PROPERTY_IMG_768_VALUE']);
            $img767=CFile::GetPath($arFields['PROPERTY_IMG_767_VALUE']);
            $photocontent.='<figure class="swiper-slide">
                <picture>
                    <source media="(min-width: 1921px)" srcset="'.$img1921.'" type="image/webp">
                    <source media="(min-width: 768px)" srcset="'.$img768.'" type="image/webp">
                    <source media="(max-width: 767px)" srcset="'.$img767.'" type="image/webp">
                    <img src="'.$img.'" srcset="'.$img.'" alt="Картинка" width="801" height="818" loading="lazy">
                </picture>
                <figcaption>'.$arFields['NAME'].'</figcaption>
            </figure>';

        }
    }
$photocontent.='
        </div>
    </div>
</div>';
   $arResult['DETAIL_TEXT']=str_replace("PHOTOGALLERY", $photocontent,  $arResult['DETAIL_TEXT']);
}
