Answer the question
In order to leave comments, you need to log in
How to resize an image?
How to resize an image if there is only one array with the path to the image?
[PREVIEW_PICTURE_SRC] => /upload/iblock/0ff/jvdg3y94o8fhfgjmzxj0c3vodb7eosd8.png
$resize = CFile::ResizeImageGet(
$img['PREVIEW_PICTURE_SRC'],
Array('width'=>260,
'height'=>260),
BX_RESIZE_IMAGE_EXACT,
true
);
$arResult["ITEMS"][$key]['PREVIEW_PICTURE']['SRC'] = $resize['src'];
Answer the question
In order to leave comments, you need to log in
And who prevents you from assigning the resulting value to any key convenient for you and using it already?
$arResult["ITEMS"][$key]['NEW_PREVIEW_PICTURE_SRC'] = $resize['src'];
Well, it's certainly PPC how strange, but somehow
$resize = [];
$filePath = '/upload/iblock/0ff/jvdg3y94o8fhfgjmzxj0c3vodb7eosd8.png';
$arFilePath = explode('/', $filePath);
$fileName = $arFilePath[array_key_last($arFilePath)];
$iterator = \Bitrix\Main\FileTable::getList([
'select' => ['ID'],
'filter' => ['FILE_NAME' => $fileName],
]);
if($row = $iterator->fetch()) {
$resize = CFile::ResizeImageGet($row['ID'], ['width'=>260, 'height'=>260], BX_RESIZE_IMAGE_EXACT, true);
}
print_r($resize);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question