Для имаг в категории (формат browse_x.php)
Файл /administrator/components/com_virtuemart/classes/class.img2thumb.php Функция function NewImgResize($orig_img,$newxsize,$newysize,$filename), примерно 178 строка, меняем на
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
function NewImgResize($orig_img,$newxsize,$newysize,$filename)
{
//$newxsize; //new width
//$newysize; //new height
$orig_size = getimagesize($filename);
$heightRatio = $orig_size[1]/$newysize;
$widthRatio = $orig_size[0]/$newxsize;
if($heightRatio < $widthRatio){
$optimalRatio = $heightRatio;
} else {
$optimalRatio = $widthRatio;
}
$optimalHeight = $orig_size[1]/$optimalRatio;
$optimalWidth = $orig_size[0]/$optimalRatio;
$imageResized = imagecreatetruecolor($optimalWidth, $optimalHeight);
$bgfill = imagecolorallocate( $imageResized, $this->bg_red, $this->bg_green, $this->bg_blue );
imagealphablending($imageResized, false);
imagesavealpha($imageResized,true);
$transparent = imagecolorallocatealpha($imageResized, 255, 255, 255, 127);
imagecopyresampled($imageResized, $orig_img, 0, 0, 0, 0, $optimalWidth, $optimalHeight, $orig_size[0], $orig_size[1]);
$cropStartX = ( $optimalWidth / 2) - ( $newxsize /2 );
$cropStartY = ( $optimalHeight/ 2) - ( $newysize/2 );
$crop = $imageResized;
$imageResized = imagecreatetruecolor($newxsize , $newysize);
$bgfill = imagecolorallocate( $imageResized, $this->bg_red, $this->bg_green, $this->bg_blue );
imagealphablending($imageResized, false);
imagesavealpha($imageResized,true);
$transparent = imagecolorallocatealpha($imageResized, 255, 255, 255, 127);
imagecopyresampled($imageResized, $crop , 0, 0, $cropStartX, $cropStartY, $newxsize, $newysize , $newxsize, $newysize);
return $imageResized;
}
|
Затем /components/com_virtuemart/show_image_in_imgtag.php Комментим следующее, строки 69-76
1
2
3
4
5
6
7
8
|
//if( $newxsize < $newysize ) {
// Don't let $newxsize be smaller than 55% of $newysize
//$newxsize = max( $newxsize, 0.55 * $newysize );
//}
//elseif( $newysize < $newxsize ) {
// Don't let $newysize be smaller than 55% of $newxsize
//$newysize = max( $newysize, 0.55 * $newxsize );
//}
|
Затем /administrator/components/com_virtuemart/classes/ps_product_category.php Примерно строка 920, функция function get_child_list($category_id) {, добавляем запросы на полную имагу категории. Вся функция
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
function get_child_list($category_id) {
global $sess, $ps_product, $VM_LANG;
$ps_vendor_id = $_SESSION["ps_vendor_id"];
$db = new ps_DB;
$childs = array();
$q = "SELECT category_id, category_thumb_image, category_full_image, category_child_id,category_name FROM #__{vm}_category,#__{vm}_category_xref ";
$q .= "WHERE #__{vm}_category_xref.category_parent_id='$category_id' ";
$q .= "AND #__{vm}_category.category_id=#__{vm}_category_xref.category_child_id ";
$q .= "AND #__{vm}_category.vendor_id='$ps_vendor_id' ";
$q .= "AND #__{vm}_category.category_publish='Y' ";
$q .= "ORDER BY #__{vm}_category.list_order, #__{vm}_category.category_name ASC";
$db->setQuery($q);
$db->query();
while( $db->next_record() ) {
$childs[] = array (
'category_name' => $db->f("category_name"),
'category_id' => $db->f("category_id"),
'category_thumb_image' => $db->f("category_thumb_image"),
'category_full_image' => $db->f("category_full_image"),
'number_of_products' => ps_product_category::products_in_category( $db->f("category_id")),
);
}
return $childs;
}
|
Далее заменяем вывод картинок:
для категории
1
|
<?php echo ps_product::image_tag(basename($product_full_image), 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"',1,'product',210,210 ); ?>
|
для подкатегорий /components/com_virtuemart/themes/default/templates/common/categoryChildlist.tpl.php, строки 26-33
1
2
3
4
5
6
7
8
|
<?php
if ( $category["category_full_image"] ) {
echo ps_product::image_tag( $category["category_full_image"], "alt=\"".$category["category_name"]."\"", 1, "category",300,300);
echo "\n";
}
echo '<div class="catlink">'.$category["category_name"].'</div><!-- end catlink -->';
echo $category['number_of_products'];
?>
|
для карточки товара не создавать
Основа http://forum.virtuemart.net/index.php?topic=84423.msg297547
Для карточки товара можно сделать следующее: administrator/components/com_virtuemart/classes/ps_product.php, строка 1413
1
2
3
4
5
6
7
8
|
if(PSHOP_IMG_RESIZE_ENABLE == '1' && $resize==1) {
$url = $mosConfig_live_site."/components/com_virtuemart/show_image_in_imgtag.php?filename=".urlencode($image)."&newxsize=".PSHOP_IMG_WIDTH."&newysize=".PSHOP_IMG_HEIGHT."&fileout=";
if( !strpos( $args, "height=" )) {
$arr = @getimagesize( vmImageTools::getresizedfilename( $image, $path_appendix, '', $thumb_height, $thumb_width ) );
$width = $arr[0]; $height = $arr[1];
}
}
|
меняем на
1
2
3
4
5
6
7
8
9
10
11
|
if(PSHOP_IMG_RESIZE_ENABLE == '1' && $resize==1) {
if($thumb_width == 0 && $thumb_height == 0){
$url = $mosConfig_live_site."/components/com_virtuemart/show_image_in_imgtag.php?filename=".urlencode($image)."&newxsize=".PSHOP_IMG_WIDTH."&newysize=".PSHOP_IMG_HEIGHT."&fileout=";
}else{
$url = $mosConfig_live_site."/components/com_virtuemart/show_image_in_imgtag.php?filename=".urlencode($image)."&newxsize=".$thumb_width."&newysize=".$thumb_height."&fileout=";
}
if( !strpos( $args, "height=" )) {
$arr = @getimagesize( vmImageTools::getresizedfilename( $image, $path_appendix, '', $thumb_height, $thumb_width ) );
$width = $arr[0]; $height = $arr[1];
}
}
|
В карточке товара пишем
1
2
|
<a class="prodmainimage" href="/<?php echo 'components/com_virtuemart/shop_image/product/'.basename($product_full_image) ?>" rel="lightbox[<?php echo 'product'.$product_id ?>]"><?php echo ps_product::image_tag(basename($product_full_image), 'title="'.$product_name.'" alt="'.$product_name .'"',1,'product',500,500 );
?></a>
|
где 500 и 500 - размеры. Все.
|