News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Problem with Product Images 1

Started by doorknob, April 21, 2008, 00:01:03 AM

Previous topic - Next topic

doorknob

When creating a new product, the processing to create the thumbnail image is completed before the data is validated. This can result in the new record being rejected but the thumbnail being created. When the problem with the new record is resolved, a new thumbnail is then created.

The processing to create the thumbnail should only be carried out when the validation has been completed and it is known that the new record will be created.

There were other problems that I will put into other posts

J1.5.2
VM 1.1 Nightly build 20/4/2008

doorknob

As described in my previous post, I entered a new product record in a way that would ensure that it would be rejected (omitted to select a category). The error was detected and reported but the selected product  image had been cleared so that when the reported error was fixed and the record saved, the image was left blank.

J1.5.2
VM 1.1 Nightly build 20/4/2008

doorknob

#2
The process of managing product images seems to have a number of issues. I completed the following sequence of events with the creation of the following images:

1 Attempt to add a new product that failed because the category was not specified. An image had been selected on the appropriate tab through the file selection dialogue and the auto create thumbnail option selected.
  No image was created in the shop_image/product folder
  Two images (both thumbnails) were created in the shop_image/product/resized folder

2 The error was corrected and the record re-submitted with a different image specified (so that I could easily distinguish the difference)
  Two images were created in the shop_image/product folder. One was full size, the other a thumbnail.
  Two images were created in the shop_image/product/resized folder. Both were thumbnails.

3 I then edited the same record and changed the image. One of the two thumbnails in the 'resized' folder was deleted. Neither of the files in the 'product' folder was deleted and the following php error was generated

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in {localhost base name}\administrator\components\com_virtuemart\classes\class.img2thumb.php on line 258

Warning: imagedestroy(): supplied argument is not a valid Image resource in {localhost base name}\administrator\components\com_virtuemart\classes\class.img2thumb.php on line 170

Warning: getimagesize({localhost base name}/components/com_virtuemart/shop_image/product/resized/name1_480bba3a72466_125x125) [function.getimagesize]: failed to open stream: No such file or directory in {localhost base name}\administrator\components\com_virtuemart\classes\class.img2thumb.php on line 363

Warning: imagecopyresampled(): supplied argument is not a valid Image resource in {localhost base name}\administrator\components\com_virtuemart\classes\class.img2thumb.php on line 258

Warning: imagedestroy(): supplied argument is not a valid Image resource in {localhost base name}\administrator\components\com_virtuemart\classes\class.img2thumb.php on line 170

Warning: copy({localhost base name}/components/com_virtuemart/shop_image/product/resized/name1_480bba3a72466_125x125) [function.copy]: failed to open stream: No such file or directory in {localhost base name}\administrator\components\com_virtuemart\classes\imageTools.class.php on line 310

On examining the database, I found that, although one of the two thumbnails had been deleted, its name was still held in the product table in the database.

I am using
J1.5.2
VM 1.1 Nightly build 20/4/2008 installed from the manual installation package for J1.5 (completely unmodified)
Simple layout

Regards
Phil


doorknob

#4
Peter,
There are several problems here.
1 When an error is detected in the product maintenance form, none of the values associated with images is restored to the refreshed form. I don't have a fix for this, although it doesn't seem like rocket science.

2 When an error is detected, the image has been uploaded and a thumbnail created but the names of these files are not saved. I have a simple fix which is to block that processing if any other error has been detected. I did that by changing classes/ps_product.php lines 127 & 150 (build 1723) from
if (!vmImageTools::validate_image($d,"product_thumb_image","product")) {

to
if ($valid == true && !vmImageTools::validate_image($d,"product_thumb_image","product")) {


3 The maintenance of product records sometimes results in unwanted images being left in the shop_image/product directory. I fixed this for my own site by writing a small program that scans the files in the category, product and vendor directories and removes any file that is not referenced in the appropriate field in the database.

Regards
Phil