Answer the question
In order to leave comments, you need to log in
How to reduce the Bitrix product photo?
Good day.
Shoveled a bunch of forums and answers to this topic on the forums.
Somewhere I'm doing something wrong.
I tried to set the standard image resize with a maximum value of 100 in the infoblock settings, but it did not help.
And there are more suggestions, paste the code in the place you need.
But I don’t know where this is the right place)
Please tell me ...
I’ve been sitting for 7 hours already .... I’m
displaying goods with a standard top element catalog.
Or do you need to send others?
Thanks in advance for your reply
Answer the question
In order to leave comments, you need to log in
This can be done through an event handler.
In the file /bitrix/php_interface/init.php add two handlers:
AddEventHandler("iblock", "OnAfterIBlockElementAdd","OnAfterIBlockElementUpdateHandler");
AddEventHandler("iblock", "OnAfterIBlockElementUpdate","OnAfterIBlockElementUpdateHandler");
function OnAfterIBlockElementUpdateHandler(&$arFields){
CModule::IncludeModule("iblock");
# массив элемента доступен в $arFields, детальная картинка, соответственно,
# в $_FILES['DETAIL_PICTURE']
# меняем картинку так, как нам нужно с помощью imageresize()
# после чего получившийся результат пишем для элемента с ID = $arFields['ID']
}
The product image can be resized in several ways:
1st - Set the IB settings, but this is not the right approach IMHO, because when you want to make bigger pictures, it turns out that there are already a lot of goods with small pictures and you will need to re-upload it all.
2nd - Set the component settings, if it supports it in the default options, add the template https://dev.1c-bitrix.ru/api_help/main/reference/c...
yes, anywhere.
even when loading, even when outputting.
But for starters, it would be nice to still clearly identify the problem.
You need the CFile::ResizeImageGet() function . And in order to postpone the cutting of photos and not delay the page loading speed for buyers, you can install the module “ Preliminary cutting of photos of infoblock elements ”.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question