K
K
kabashowlab2015-07-12 23:23:08
PHP
kabashowlab, 2015-07-12 23:23:08

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

5 answer(s)
A
Andrey, 2015-07-13
@kabashowlab

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");

then you create a function where this processing actually happens:
function OnAfterIBlockElementUpdateHandler(&$arFields){
  CModule::IncludeModule("iblock");
# массив элемента доступен в $arFields, детальная картинка, соответственно, 
# в $_FILES['DETAIL_PICTURE']
# меняем картинку так, как нам нужно с помощью imageresize()
# после чего получившийся результат пишем для элемента с ID = $arFields['ID']
}

Well, this is a "paste code blah blah blah" solution.
In fact, with Bitrix, an ambush can be in the most unpredictable place. For example, in the photo gallery, in addition to PREVIEW_PICTURE and DETAIL_PICTURE, the REAL_PICTURE entity was introduced, once I figured out for a very long time why the loaded pictures are not displayed by me :-\
In addition, I recommend checking:
- cache time. Perhaps the pictures are completely resized, but the old version is displayed. Flush cache. Just in case, open the image in a new window and CTRL + R (this is not for Bitrix, but for nginx, if available)
- In the infoblock settings, in addition to the "Fields" tab, check "Section fields"
- since we are talking about a directory, it's a good idea to check which IB the directory works with. Since it is possible that when installing the "Trade catalog" module, a new IB was created with trade offers.

J
Julia Bedrosova, 2015-07-12
@Bedrosova

Take the Resizer module from the market.

M
Maksim Zverev, 2015-07-12
@m1skam

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...

R
Rad1calDreamer, 2015-07-13
@Rad1calDreamer

yes, anywhere.
even when loading, even when outputting.
But for starters, it would be nice to still clearly identify the problem.

O
Oleg Maksimenko, 2015-07-14
@olegprof

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 question

Ask a Question

731 491 924 answers to any question