P
P
photosho2021-05-17 13:31:13
1C-Bitrix
photosho, 2021-05-17 13:31:13

How to properly scale an image when adding an infoblock element?

I'm trying to change the size of the "PREVIEW_PICTURE" image when adding an infoblock element:

AddEventHandler('iblock', 'OnAfterIBlockElementAdd', 'OnAfterIBlockElementAddHandler');

function OnAfterIBlockElementAddHandler(&$arFields){
  CModule::IncludeModule('iblock');
  
  CAllFile::resizeImage(
    $arFields['PREVIEW_PICTURE'],
    ['width' => 405, 'height' => 300],
    BX_RESIZE_IMAGE_PROPORTIONAL
  );
}


The image remains unchanged. What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
PetrPo, 2021-05-18
@photosho

The question does not specify that it is a CSV import.
Need to tick
60a286a1158ba173845142.jpeg

A
Alexander, 2021-05-17
@idruweb

I need to save the result somewhere.

I
I'm Yoda, 2021-05-17
@Anadi

$arTmpImage = \CFile::ResizeImageGet(
            $itemPhoto["ID"],
            ["width" => 405, "height" => 300],
            BX_RESIZE_IMAGE_PROPORTIONAL, true,
            ["name" => "sharpen", "precision" => 100]
        );

You will understand further.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question