G
G
gnvs2021-08-27 16:55:13
1C-Bitrix
gnvs, 2021-08-27 16:55:13

Resize images by sort or counter?

Good time, I'm collecting a
photo gallery:
all the photos are cut in 500x500, but I need 4 photos and 8 photos to be cut in a different resolution ... 500x900.
I do not understand how to specify this to the resizer.

I use a normal resizer in result_modifier:

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();

foreach($arResult["ITEMS"] as $cell=>$arItem){

  if($arItem["PREVIEW_PICTURE"]['ID']){
    $file = CFile::ResizeImageGet($arItem["PREVIEW_PICTURE"]['ID'],array("width" => 500, "height" => 500), BX_RESIZE_IMAGE_EXACT, true);
    $arResult["ITEMS"][$cell]["PREVIEW_PICTURE"]['WIDTH'] = $file['width'];
    $arResult["ITEMS"][$cell]["PREVIEW_PICTURE"]['HEIGHT'] = $file['height'];
    $arResult["ITEMS"][$cell]["PREVIEW_PICTURE"]['SRC'] = $file['src'];
  }

  /*кеш*/
  if($file['src'])
      $file['src'] = \CUtil::GetAdditionalFileURL($file['src'], true);
      $arItem['PREVIEW_PICTURE'] = array_change_key_case($file, CASE_UPPER);

}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maiker, 2021-08-30
@Maiker

The most obvious thing is to make an array with the required dimensions for each image and take the dimensions from there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question