могу привести пример.
свой, при загрузке детальной картинки, сжимается, и из нее, при желании создается маленькая.
1. идем в /bitrix/modules/iblock/admin/iblock_element_edit.php
правим
теперь, в \ bitrix\ php_interface\ include
создаем файл iblock_element_edit_before_save.php
В крации,
если создаем маленькую картинку из большой, то она будет сжиматься до ширины равной 70.(для JPG и GIF)
если только большую, то она сжимается до ширины равной 200.
думаю, можно разобраться.
помоглаhttp://www.1c-bitrix.ru/help/index.html?page=source%2Fiblock%2Fhelp%2Fru%2Fdeveloper%2Fcustom.php.html
свой, при загрузке детальной картинки, сжимается, и из нее, при желании создается маленькая.
1. идем в /bitrix/modules/iblock/admin/iblock_element_edit.php
правим
Код |
---|
<tr> <td width="40%"><?echo GetMessage("IBLOCK_ACTIVE")?></td> <td width="60%"><input type="checkbox" name="ACTIVE" value="Y"<?if($str_ACTIVE=="Y")echo " checked"?>></td> </tr> <tr> <td><?echo GetMessage("IBLOCK_ACTIVE_PERIOD")?>(<?echo CLang::GetDateFormat("SHORT");?>)</td> <td><?echo CalendarPeriod("ACTIVE_FROM", $str_ACTIVE_FROM, "ACTIVE_TO", $str_ACTIVE_TO, "form_element", "N", "", "", "19")?></td> </tr> <tr> <td><span class="required">*</span><?echo GetMessage("IBLOCK_NAME")?></td> <td> <input type="text" name="NAME" size="50" maxlength="255" value="<?echo $str_NAME?>"> </td> </tr> <?if(count($PROP)>0):?> <tr class="heading"> <td colspan="2"><?echo GetMessage("IBLOCK_ELEMENT_PROP_VALUE");?></td> </tr> <? foreach($PROP as $prop_code=>$prop_fields): $prop_values = $prop_fields["VALUE"]; ?> <tr> <td valign="top"><?echo htmlspecialcharsex($prop_fields["NAME"]);?>:</td> <td><?_ShowPropertyField('PROP['.$prop_fields["ID"].']', $prop_fields, $prop_values, ((!$bVarsFromForm) && ($ID<=0)), $bVarsFromForm);?></td> </tr> <?endforeach;?> <?endif?> <? if ($view!="Y" && CModule::IncludeModule("catalog") && CCatalog::GetByID($IBLOCK_ID)) { include($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/catalog/admin/templates/product_edit.php"); } ?> <? $tabControl->BeginNextTab(); ?> <tr> <td nowrap valign="top" width="40%"><?echo GetMessage("IBLOCK_PICTURE")?></td> <td width="60%"> <?echo CFile::InputFile("PREVIEW_PICTURE", 20, $str_PREVIEW_PICTURE, false, 0, "IMAGE", "", 40);?><br> <?echo CFile::ShowImage($str_PREVIEW_PICTURE, 200, 200, "border=0", "", true)?> </td> </tr> <?if(COption::GetOptionString("iblock", "use_htmledit", "Y")=="Y" && CModule::IncludeModule("fileman")):?> <tr> <td colspan="2" align="center"> <?CFileMan::AddHTMLEditorFrame( "PREVIEW_TEXT", $str_PREVIEW_TEXT, "PREVIEW_TEXT_TYPE", $str_PREVIEW_TEXT_TYPE, 300, "N", 0, "", "", $arIBlock["LID"] );?> </td> </tr> |
теперь, в \ bitrix\ php_interface\ include
создаем файл iblock_element_edit_before_save.php
Код |
---|
<? function BXIBlockAfterSave($arFields) { if($_POST['MAKE_PREVIEW_PICTURE']=='Y') { $dbr = CIBlockElement::GetByID($arFields['ID']); if(($ar = $dbr->Fetch()) && $ar['DETAIL_PICTURE']>0) { $img_path = $_SERVER['DOCUMENT_ROOT'].CFile::GetPath($ar['DETAIL_PICTURE']); $width = 70; $height =200; list($width_orig, $height_orig) = getimagesize($img_path); $height = ($width / $width_orig) * $height_orig; $image_p = imagecreatetruecolor($width, $height); $ext=strstr($img_path,"."); if($ext==".gif"){ $image = imagecreatefromgif($img_path); imagecopyresized($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $new_img_path = tempnam("/tmp", "FOO").".gif"; imagegif($image_p, $new_img_path); $be = new CIBlockElement(); $be->Update($arFields['ID'], Array('PREVIEW_PICTURE' => CFile::MakeFileArray($new_img_path)), false); @unlink($new_img_path); } else{ $image = imagecreatefromjpeg($img_path); imagecopyresized($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $new_img_path = tempnam("/tmp", "FOO").".jpg"; imagejpeg($image_p, $new_img_path); $be = new CIBlockElement(); $be->Update($arFields['ID'], Array('PREVIEW_PICTURE' => CFile::MakeFileArray($new_img_path)), false); @unlink($new_img_path); } } } $dbr = CIBlockElement::GetByID($arFields['ID']); if(($ar = $dbr->Fetch()) && $ar['DETAIL_PICTURE']>0) { $img_path = $_SERVER['DOCUMENT_ROOT'].CFile::GetPath($ar['DETAIL_PICTURE']); $width = 200; $height =570; list($width_orig, $height_orig) = getimagesize($img_path); $height = ($width / $width_orig) * $height_orig; if($width_orig<=$width) {$width = $width_orig; $height= $height_orig;} $image_p = imagecreatetruecolor($width, $height); $ext=strstr($img_path,"."); if($ext==".gif"){ $image = imagecreatefromgif($img_path); imagecopyresized($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $new_img_path = tempnam("/tmp", "FOO").".gif"; imagegif($image_p, $new_img_path); $be = new CIBlockElement(); $be->Update($arFields['ID'], Array('DETAIL_PICTURE' => CFile::MakeFileArray($new_img_path)), false); @unlink($new_img_path); } else{ $image = imagecreatefromjpeg($img_path); imagecopyresized($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); $new_img_path = tempnam("/tmp", "FOO").".jpg"; imagejpeg($image_p, $new_img_path); $be = new CIBlockElement(); $be->Update($arFields['ID'], Array('DETAIL_PICTURE' => CFile::MakeFileArray($new_img_path)), false); @unlink($new_img_path); } } } ?> |
В крации,
если создаем маленькую картинку из большой, то она будет сжиматься до ширины равной 70.(для JPG и GIF)
если только большую, то она сжимается до ширины равной 200.
думаю, можно разобраться.
помогла
----------------------------------
Создание сайтовCтудия Web дизайна Colorado
Создание сайтов