D
D
Darklt2018-05-20 06:41:33
1C-Bitrix
Darklt, 2018-05-20 06:41:33

How to display a picture for the announcement from the add. infoblock images in Bitrix?

There are goods in the catalog, but images were uploaded in bulk to the custom property "SYSTEM_IMAGES",
in the catalog.section list the output comes only from the Image from the Announcement, if it is not filled in, then there will be no photo.
The trick is that there is a solution and there the image output template is like this:

$sPictureSrc = ArrayHelper::getValue($arElement, ['PICTURE', 'src']);

and the output is like this:
<?= Html::img($sPictureSrc, $arPictureAttributes) ?>

Here's how to do that if there is no picture here, then insert the path like this:
<?= $arElement["DISPLAY_PROPERTIES"]["SYSTEM_IMAGES"]["FILE_VALUE"]["0"]["SRC"] ?>

Need to take the first picture of the item
Thank you in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vasya, 2018-05-20
@haramba

if ($sPictureSrc && file_exists($_SERVER["DOCUMENT_ROOT"].$sPictureSrc))

D
Darklt, 2018-05-20
@Darklt

Found an easier solution:

<?if ($arElement["PREVIEW_PICTURE"] > 0) { ?>

<img src="<?=$arElement["PREVIEW_PICTURE"]["SRC"]?>" />
<?} else {  ?>

<img src="<?= $arElement["DISPLAY_PROPERTIES"]["SYSTEM_IMAGES"]["FILE_VALUE"]["0"]["SRC"] ?>" />
<?} ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question