首页 > Joomla > VirtueMart使用三种不同级别的图

VirtueMart使用三种不同级别的图

2009年5月7日

virtumart的用图级别只有2种,一种是缩略图,一种是大图(点击查看详细时弹出的ajax)。但一般的商务网站用图级别有3种,浏览商品时用缩略图,打开后用中图,点击时弹出ajax大图。所以virtumart在打开商品时只看缩略图太不方便了。

原帖地址:http://forum.virtuemart.net/index.php?topic=14861

UPDATED 01-31-06: Large images can now be manually uploaded like the small and medium thumbnails. Minor bugfixes and small code optimization.
UPDATED 01-26-06: Major bugfix

 I finally figured it out! (Sorry to everyone on the board for my incessant pestering about this). Ok so this quick guide will show you how to make Virtuemart use 3 separate images for the product listing, product details, and view larger image. This was done using Virtuemart 1.0.2 and Joomla 1.07. First let me point out the benefits to this method:

Obviously, you get a small thumb when quickly browsing through items, a detailed image on the individual flypage, and a full size image for detailed viewing
Instead of dynamically resizing images this method lets you upload your own resized/optimized images to decrease page load times (essential for keeping customers on your website)
You can upload all your images using FTP which is faster than adding thumbnails for each product through the backend
I hope there won’t be a need for this code modification in the future and that it will become a standard feature in Virtuemart. We’ll get started in a second, but first a small disclaimer: This involved modifying VM’s core files, MAKE BACKUP COPIES OF THE FILES BEING MODIFIED. I have no programming knowledge, just common sense and logic, this is definately not optimized code so I would appreciate any suggestions or bug fixes. Ok now onto the process.
Step 1. First open the html/shop.browse.php to modify the product listing page. Find the code

1
"$product_thumb_image = IMAGEURL.NO_IMAGE;"

near line 293 and replace it with the following code:
Code:

1
"$product_thumb_image = "images/products/".$db_browse->f("product_sku")."_sm.jpg";

NOTE: You can change the path where you will upload your images, “images/products/”, to whatever you like. Currently the relative path points to http://yourdomain.com/images/products/. You can also change the name of the image suffix name “_sm.jpg” to whatever you like.

Step 2. Now we will edit the product flypage, open html/shop.product_details.php. Go to around line 227 and comment out

1
"//if( file_exists( IMAGEPATH."product/$full_image" )) {" so that it becomes "//if( file_exists( IMAGEPATH."product/$full_image" )) {".

Step 3. Next find the code

1
"if( $image_info = @getimagesize(IMAGEPATH."product/$full_image") ) {"

around line 230. Now replace it with:
Code:

1
if( $image_info = @getimagesize("<a href="http://www.laurelcrownfurniture.com/images/products/%22.$db_product-%3Ef(%22product_sku%22).%22_lrg.jpg">http://www.laurelcrownfurniture.com/images/products/".$db_product-&gt;f("product_sku")."_lrg.jpg</a>") ) {

Step 4. Go to around line 244 and find the code

1
2
"$text = $ps_product-&gt;image_tag($product_thumb_image, "alt="".$product_name.""", 1)."&lt;br/&gt;".$VM_LANG-&gt;_PHPSHOP_FLYPAGE_ENLARGE_IMAGE;
"

. Now replace it with:
Code:

1
$text = "&lt;img src="images/products/".$db_product-&gt;f("product_sku")."_med.jpg" border="0" alt="".$product_name.""&gt;"."&lt;br/&gt;".$VM_LANG-&gt;_PHPSHOP_FLYPAGE_ENLARGE_IMAGE;

NOTE: Same as above, change the image directory and suffix as needed. You can also change “$lcdb” (temporary database) to whatever variable you want starting with “$”.
Step 5. Go to around line 216 and find the code ”

1
2
if( empty($full_image ) ) {". Replace it with:
Code:if( !file_exists( "images/products/".$db_product-&gt;f("product_sku")."_lrg.jpg" )) {

NOTE: images/products/ is the relative path to your product images directory.

Congratulations! You’re done! Easy right? Ok now let me explain how to get this baby working. What we’ve done is essentially make Virtuemart look for small and medium thumbnail images in the directory of your website www.yourdomain.com/images/products/. This is the directory you will upload your small, medium and large size images to, you don’t even have to change anything through the VM backend just name your images [PRODUCT SKU]_sm.jpg, [PRODUCT SKU]_med.jpg and [PRODUCT SKU]_lrg.jpg where [PRODUCT SKU] is the SKU of the product whose image you want to display. For example I have a Four Poster Bed with the product_sku: BM233 than I would simply name my thumbnails, BM233_sm.jpg, BM233_med.jpg and BM233_lrg.jpg and the script will automatically find and use them.

(Thanks to deneb for the code optimization.)
 
« Last Edit: January 31, 2006, 10:20:12 am by syclonix »

作者: 分类: Joomla 标签: ,
声明:本站遵循 署名-非商业性使用-相同方式共享 3.0 共享协议. 转载请注明转自 执子之手与子偕老
  1. 本文目前尚无任何评论.
  1. 2014年6月22日23:00 | #1
  2. 2014年9月23日13:47 | #2
  3. 2014年10月2日21:01 | #3
  4. 2014年10月3日02:53 | #4
  5. 2014年10月5日21:03 | #5
  6. 2014年10月8日20:47 | #6
  7. 2014年10月19日08:56 | #7
  8. 2014年10月20日07:45 | #8
  9. 2014年10月20日07:59 | #9
  10. 2014年10月27日09:09 | #10
  11. 2014年10月30日00:39 | #11
  12. 2014年11月13日07:52 | #12