I
I
IgorRastarov2017-05-04 11:00:55
1C-Bitrix
IgorRastarov, 2017-05-04 11:00:55

How to display a description of photos in Bitrix?

Hello. I can't display photo descriptions.
result_modifier.php

foreach ($arResult["PROPERTIES"]["PHOTO"]["VALUE"] as $imageId) 
  {
  $photo=CFile::GetFileArray($imageId);
  $arResizeFile = CFile::ResizeImageGet(
     $photo["ID"],
     $photo["DESCRIPTION"],
     //array("width" => $photo["WIDTH"], 'height' => $photo["HEIGHT"]),
     array("width" => 700, 'height' => $photo["HEIGHT"]),
     BX_RESIZE_IMAGE_PROPORTIONAL_ALT,
     true,
     $arWaterMark
  );
    $arResult["PHOTO"][] = $arResizeFile;
  }

template.php
<?foreach ($arResult["PHOTO"] as &$PhotoItem) {?>
<?var_dump($arResult["PHOTO"]["DESCRIPTION"]);?>//пишет NULL
<img  alt="" title="" src="<?= $PhotoItem['src']?>" width="700">
<?}?>

Moreover, the Description is not empty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2017-05-04
@rpsv

So you need to access the element:

<?php foreach ($arResult['PHOTO'] as $PhotoItem):
    $src = $PhotoItem['SRC'];
    $desc = $PhotoItem['DESCRIPTION'];
?>
<img  alt="<?= $desc ?>" title="<?= $desc ?>" src="<?= $src ?>" width="700">
<?php endforeach; ?>

And a little review:
1. there is no need to make the element referential &$PhotoItem
2. use the construction "foreach: endforeach;" if output like this (it reads better)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question