Working with images in Bitrix
Работа с изображением в Битрикс D7

All English-language materials have been translated fully automatically using the Google service

Get the full path to the image in Bitrix


We get the result:


Resize images

// We can use the following conversion constants:
//BX_RESIZE_IMAGE_EXACT —scales to rectangle $ arSize keeping proportions, cutting off excess;
//BX_RESIZE_IMAGE_PROPORTIONAL —scales proportionally, the size is limited to $ arSize;
//BX_RESIZE_IMAGE_PROPORTIONAL_ALT — scales proportionally, the size is limited to $ arSize, improved handling of vertical images.

$arFileTmp = CFile::ResizeImageGet(
	array("width" => 1000, "height" => 1000),
echo $arFileTmp["src"];

Upload and update image

Form an array from the loaded image. For example, to update the image in the product

$arFile = CFile::MakeFileArray($_SERVER["DOCUMENT_ROOT"]."PATH_TO_IMAGE");

Returns an array of the following type

    [name] => caa99553003f620f2b1ed91ebb7129e1.jpg
    [size] => 913948
    [tmp_name] => /home/bitrix/www/upload/tmp/434/caa99553003f620f2b1ed91ebb7129e1.jpg
    [type] => image/jpeg

Let's update, for example, the photo of the section

$arFile = CFile::MakeFileArray('PATH_TO_IMAGE');

// To get the data array of the already loaded image
// Let's use the following construction
//$arFile = CFile::GetFileArray('ID_OF_IMAGE');

$arPICTURE = $arFile;
$arPICTURE["MODULE_ID"] = "iblock";

$bs = new CIBlockSection;

$arFields = Array(

//$ar_result['ID'] -ID of the section being updated
$res = $bs->Update($ar_result['ID'], $arFields, false, false, true);


$el = new \CIBlockElement;
$el->Update($ELEMENT_ID, array(
    "PREVIEW_PICTURE" => array('del' => 'Y'),
    "DETAIL_PICTURE" => array('del' => 'Y'),
), false, false);

Removing photos from MORE_PHOTO

\CIBlockElement::SetPropertyValuesEx($ELEMENT_ID, $IBLOCK_ID, array("MORE_PHOTO" => array("VALUE" => array("del" => "Y"))));


There are no comments yet, you can be the first to leave it

Leave a comment

The site uses a comment pre-moderation system, so your message will be published only after approval by the moderator

You are replying to a user's comment



Email me

Are you developing a new service, making improvements to the existing one and want to be better than your competitors? You have come to the right place. I offer you a comprehensive studio-level website development. From me you can order design, layout, programming, development of non-traditional functionality, implementation of communication between CMS, CRM and Data Analitics, as well as everything else related to sites, except for promotion.

Contact, I will always advise on all questions and help you find the most effective solution for your business. I am engaged in the creation of sites in Novosibirsk and in other regions of Russia, I also work with the CIS countries. You will be satisfied with our cooperation

An error occurred while sending, please try again after a while
Message sent successfully


+7(993) 007-18-96



Россия, г. Москва

By submitting the form, you automatically confirm that you have read and accept the Privacy Policy site

Contact with me
Send message
By submitting the form, you automatically confirm that you have read and accept Privacy policy of site
Sending successful!
Thank you for contacting :) I will contact you as soon as possible
Sending failed
An error occurred while sending the request. Please wait and try again after a while or call my phone number