E
E
Eugene M2018-07-09 23:28:06
1C-Bitrix
Eugene M, 2018-07-09 23:28:06

How to resize an image in Bitrix?

I create a completely new property CONSULTANT_FOTO how to display and resize it?
It turned out to withdraw, but resize is no longer possible.

<? $file_path = CFile::GetPath($arResult['DISPLAY_PROPERTIES']['CONSULTANT_FOTO']['VALUE']); ?>
<img src="<?= $file_path ?>" width="247px" height="auto"/>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Kazakov, 2018-07-10
@hotwind

If you resize on the fly and cache the reduced image (it returns it again from the cache), then try using the CFile::ResizeImageGet
class. Theoretically, this code should work like this (if CONSULNANT_FOTO is a property of the "file" type, not a string) :

<?
$wsize = 100; // новая ширина 100 пикселей
$hsize = 100; // новая высота 100 пикселей
$file_path = CFile::ResizeImageGet(
        $arResult['DISPLAY_PROPERTIES']['CONSULTANT_FOTO']['VALUE'], // ID файла 
        Array("width" => $wsize, "height" => $hsize),
        BX_RESIZE_IMAGE_EXACT, // тип масштабирования, подробнее в документации по ссылке выше
        false);
?>
<img src="<?=$file_path['src']?>" width="<?=$wsize?>" height="auto"/>

It remains to set the sizes for yourself in variables and it is possible to experiment with the type of scaling.

_
_umr, 2018-07-09
@Umr001

cfile:resizeImaget

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question