K
K
ksenia_strakhova2019-08-05 18:09:17
1C-Bitrix
ksenia_strakhova, 2019-08-05 18:09:17

How to configure the output of a detailed image of a catalog section on Bitrix?

To display a detailed image of a directory section, I use:

<?=$arSection['PICTURE']['SRC']?>
<?=$arResult['DETAIL_PICTURE']['SRC']?>

But instead of the image, the path to it (correct) is displayed, like: /upload/iblock/8e1/8e13f5b60480f83c28d82c23121be868.jpg
What is wrong with my output code?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mts2050, 2019-08-05
@ksenia_strakhova

Try like this:

<img alt="" src="<?=$arResult['DETAIL_PICTURE']['SRC']?>">

A
Alams Stoyne, 2019-08-05
@alams_stoyne

I advise you to get started

var_dump($arSection);
var_dump($arResult);

And you will understand what is generally in these variables.
I can assume that there is no array ['DETAIL_PICTURE']['SRC'] and ['PICTURE']['SRC'] but only ['DETAIL_PICTURE'] and ['PICTURE'] with file IDs, not paths to them .
To do this, use:
$image_src =  CFile::GetPath($arSection["PICTURE"]);
echo '<img src="<?=$image_src?>">';

Or how I do a resize right away:
$image =  CFile::ResizeImageGet($arSection['PICTURE'], array('width'=>1024, 'height'=>768), BX_RESIZE_IMAGE_PROPORTIONAL, true);
echo '<img src="'.$image['src'].'">';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question