Answer the question
In order to leave comments, you need to log in
How to get the value of a custom field of file type?
For sections, I added a file type field: UF_LOGO_MANUFACTURE In the catalog
catalog.element
complex component template, I add:
<?foreach ($arResult["UF_LOGO_MANUFACTURE"] as $EX):?>
<?
$arFile = CFile::GetFileArray($EX);
//print_r($arFile);
?>
<?$renderImage = CFile::ResizeImageGet($arFile, Array("width" => 820, "height" => 523), BX_RESIZE_IMAGE_EXACT);?>
<img src="<?=$renderImage['src']?>" alt="Слайд" width="820" height="523">
<?endforeach?>
Answer the question
In order to leave comments, you need to log in
Does $arResult have a UF_LOGO_MANUFACTURE field at all? First you need to get a custom field. For example like this:
$arFilter = array(
'IBLOCK_ID' => $arResult['IBLOCK_ID'],
'ID' => $arResult['IBLOCK_SECTION_ID'],
);
$arSelect = array('ID','UF_*');
$res = CIBlockSection::GetList(array(), $arFilter, false, $arSelect);
if($ar_logos = $res->GetNext())
$arLogo = $ar_logos;
<?if(!empty($arLogo['UF_LOGO_MANUFACTURE'])):{?>
<?foreach($arLogo['UF_LOGO_MANUFACTURE'] as $arLogoID):?>
if(empty($arLogoID)) break;
$arFile[$arLogoID] = CFile::GetFileArray($arLogoID);
// Ресайзим если надо
$arFileTmp = CFile::ResizeImageGet(
$arLogoID,
array("width" => 820, "height" => 523),
BX_RESIZE_IMAGE_PROPORTIONAL,
true, $arFilter
);
?>
<img src="<?=$arFileTmp["src"]?>">
<?endforeach;?>
<?}endif;?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question