I
I
IgorRastarov2017-03-24 12:33:30
1C-Bitrix
IgorRastarov, 2017-03-24 12:33:30

Why is ResizeImageGet not working in template.php?

Hello.
I fight everything. I don't understand at all. The code works everywhere, except for one template.

<?foreach ($arResult["ITEMS"] as $arItem) {?>
 <? 
 $arPicture = CFile::GetFileArray($arItem["PREVIEW_PICTURE"]);
$renderImage = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"] , Array("width" => 300, "height" => 300), BX_RESIZE_IMAGE_EXACT, false);
?>
<img src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>" alt="<?=$arSection["PREVIEW_PICTURE"]["ALT"]?>">
 <?}?>

<img src="<?=$arItem["PREVIEW_PICTURE"]["SRC"]?>" alt="<?=$arSection["PREVIEW_PICTURE"]["ALT"]?>">

Here it works
I do
var_dump ($arPicture);
writes null.
I do it to make it work
$renderImage = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"] , Array("width" => 200, "height" => 200), BX_RESIZE_IMAGE_EXACT, false);

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Zakharov, 2017-03-24
@IgorRastarov

1) You need to learn how to read the description of functions - take.ms/GjcSb
2) Pass ID

$renderImage = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"]['ID'] , Array("width" => 200, "height" => 200), BX_RESIZE_IMAGE_EXACT, false);

I
Igor Karachentsev, 2017-03-24
@kucheriavij

You write the result to $renderImage and output it from another variable. It would be correct like this:
<img src="<?=$renderImage["src"]?>" alt="">

A
Andrey Goncharov, 2017-03-24
@agmegadeth

$renderImage = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"]["ID"] , Array("width" => 300, "height" => 300), BX_RESIZE_IMAGE_EXACT, false);

$arItem["PREVIEW_PICTURE"]["ID"] must be passed

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question