Help, please, correctly set the check for the presence of the picture of the item. The default image will be in /bitrix/templates/site/images/wip.jpg. That is, if no pictures for the item are loaded, then the above is displayed. The location of the block of interest in the line, where "width" => 534, "height" => 307 is the mention of the desired section.

<div class='catalog-detail' data-val='<?=$arResult['ID'];?>'> <div class='catalog-grey-block group'> <div class='catalog-detail-left-block'> <div class="item_slider"> <ul class="slides"> <? $images = array(); if(is_array( $arResult["DETAIL_PICTURE"] ) ){$images[] = $arResult["DETAIL_PICTURE"];} foreach( $arResult["MORE_PHOTO"] as $arPhoto ){ $images[] = $arPhoto;} $bIsOneImage = count($images) == 1; ?> <?foreach( $images as $key => $arPhoto ){?> <li id="photo-<?=$key?>" <?=$key == 0 ? 'class="current"' : ''?>> <?//pr($arPhoto); //$img = CFile::ResizeImageGet( $arPhoto, array( "width" => 1000, "height" => 800 ), BX_RESIZE_IMAGE_PROPORTIONAL, true, array() );?> <?if($arResult['ID']!='1432'):?> <a rel='gallery' href="<?=$arPhoto["SRC"]?>" class='fancy' > <?endif;?> <?$img = CFile::ResizeImageGet( $arPhoto, array( "width" => 534, "height" => 307 ), BX_RESIZE_IMAGE_EXACT, true, array() );?> <img border="0" src="<?=$img["src"]?>" alt="<?=$arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"]?>" title="<?=$arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"]?>" /> <?if($arResult['ID']!='1432'):?> </a> <?endif;?> </li> <?}?> </ul> <?if(count($images) > 1 ){?> <div class="thumbs"> <ul id="thumbs"> <?foreach( $images as $key => $arPhoto ){?> <?$img = CFile::ResizeImageGet( $arPhoto, array( "width" => 130, "height" => 76 ), BX_RESIZE_IMAGE_EXACT, true, array() );?> <li <?=$key == 0 ? 'class="current"' : ''?>> <a href='javascript:void(0);'> <img border="0" src="<?=$img["src"]?>" alt="<?=$arResult["NAME"]?>" title="<?=$arResult["NAME"]?>" /> </a> </li> <?}?> <?if (count($images)>3):?><?endif;?> </ul> </div> <span class="thumbs_navigation"></span> <?}?> </div> 

    2 answers 2

    Bitrix ... hands would tear them to programmers ...

    You can check for empty the arrays $ arResult ["MORE_PHOTO"] and $ arResult ["DETAIL_PICTURE"]? If both are empty, then we show the desired picture, if not, then we make the orgy given by you.

    Something like this:

     if(empty($arResult["MORE_PHOTO"]) && empty($arResult["DETAIL_PICTURE"])){ ?> <img src="/bitrix/templates/site/images/wip.jpg" alt="" /> <?php }else{ //судя по всему остальной Ваш код } 
    • Can you tell me how to correctly register it in the template and after what? - Yuri
    • @Yuri , updated the comment, it's just a general principle - DaemonHK

    I would advise image processing logic to be put into result_modifier.php Then it would look like this:

    result_modifier.php

     <?php if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true){ die(); } $arResult['GALLERY'] = array(); $arImages = array(); if (is_array($arResult["DETAIL_PICTURE"])){ $arImages[] = $arResult["DETAIL_PICTURE"]; } foreach ($arResult["MORE_PHOTO"] as $arPhoto){ $arImages[] = $arPhoto; } if (!empty($arImages)){ foreach ($arImages as $k => $arImage){ $arResult['GALLERY'][$k]['ORIGINAL'] = $arImage; $arResult['GALLERY'][$k]['BIG'] = CFile::ResizeImageGet($arImage, array( "width" => 534, "height" => 307 ), BX_RESIZE_IMAGE_EXACT, true, array()); $arResult['GALLERY'][$k]['SMALL'] = CFile::ResizeImageGet($arImage, array( "width" => 130, "height" => 76 ), BX_RESIZE_IMAGE_EXACT, true, array());; } $arResult['GALLERY']['COUNT'] = count($arImages); unset($arImages); }else{ $arResult['GALLERY'][0]['ORIGINAL']['SRC'] = '/bitrix/templates/site/images/wip.jpg'; $arResult['GALLERY'][0]['BIG']['src'] = '/bitrix/templates/site/images/wip.jpg'; $arResult['GALLERY'][0]['SMALL']['src'] = '/bitrix/templates/site/images/wip.jpg'; $arResult['GALLERY']['COUNT'] = 1; } ?> 

    tempalte.php

     <div class='catalog-detail' data-val='<?=$arResult['ID'];?>'> <div class='catalog-grey-block group'> <div class='catalog-detail-left-block'> <div class="item_slider"> <ul class="slides"> <? foreach ($arResult['GALLERY'] as $key => $arPhoto){ ?> <li id="photo-<?=$key?>" <?=$key == 0 ? 'class="current"' : ''?>> <? if ($arResult['ID'] != '1432'): ?> <a rel='gallery' href="<?=$arPhoto["ORIGINAL"]["SRC"]?>" class='fancy'> <? endif; ?> <img border="0" src="<?=$arPhoto["BIG"]["src"]?>" alt="<?=$arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"]?>" title="<?=$arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"]?>"/> <? if ($arResult['ID'] != '1432'): ?> </a> <? endif; ?> </li> <? } ?> </ul> <? if ($arResult['GALLERY']['COUNT'] > 1){ ?> <div class="thumbs"> <ul id="thumbs"> <? foreach ($arResult['GALLERY'] as $key => $arPhoto){ ?> <li <?=$key == 0 ? 'class="current"' : ''?>> <a href='javascript:void(0);'> <img border="0" src="<?=$arPhoto["SMALL"]["src"]?>" alt="<?=$arResult["NAME"]?>" title="<?=$arResult["NAME"]?>"/> </a> </li> <? } ?> </ul> </div> <span class="thumbs_navigation"></span> <? } ?> </div> 
    • It seemed to me a difficult decision. I do not really understand this and in the result modifier I would not like to go there yet. in any other way? - Yuri