VirtueMart Forum

VirtueMart 1.1.x [ Old version - no longer supported ] => Themes & Layout Problems and Customization VM 1.1 => Topic started by: gjrweb on November 20, 2009, 15:29:46 pm

Title: Rebuild Thumbnails
Post by: gjrweb on November 20, 2009, 15:29:46 pm
I am using virtuemart 1.1.4, how to recreate thumbnails?

I have seen several topics already, but non worked for me on 1.1.4...

Thanks!
Title: Re: Rebuild Thumbnails
Post by: Forrest on January 11, 2010, 19:49:29 pm
J 1.5.15 + VM1.14

http://forum.virtuemart.net/index.php?topic=34733.msg116853

1. delete images in resized folder.
2. sql: update jos_vm_product set product_thumb_image = product_full_image

Worked like a charm with gd library working (Dynamic Thumbnail Resizing). When setting the thumb image to full image, this will clear out all the old thumbs originally created when adding a new product. Clearing out the resized folder will delete all gd (dynamically) created thumbs. Now when gd goes to make new thumbs in resized, it will us the thumbnail set in product_thumb_image, which via sql you have set to be the full image. So it will create nice, clear, resized images!
Title: Re: Rebuild Thumbnails
Post by: RikkiTikki on February 02, 2010, 19:20:56 pm
this is good idea but since i have done this thumbnails on the category page look as i wished, and on the product page they have blown my template:) does any have a clue?
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 03, 2010, 03:59:12 am
If you want help, a little more detail would be necessary. "Blown" is very un-descriptive. A link to the product page would be nice too.
Title: Re: Rebuild Thumbnails
Post by: RikkiTikki on February 03, 2010, 08:24:54 am
on the catdegory page they have the size just what i wanted, and  on the product page they are have the original size. sorry for my humour ::) u can see categories here (http://62.182.89.76/index.php?option=com_virtuemart&page=shop.browse&category_id=7&Itemid=16) & products here (http://62.182.89.76/index.php?page=shop.product_details&flypage=flypage.tpl&product_id=48&category_id=7&option=com_virtuemart&Itemid=16)
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 03, 2010, 08:40:04 am
MY guess is all you need to do is set your VM configuration setting for dynamic resize. This can be found at:

VM -> Admin -> Configuration

Check the box: Enable Dynamic Thumbnail Resizing?      
Set your: Thumbnail Image Width      
Set your: Thumbnail Image Height

That should do the trick.
Title: Re: Rebuild Thumbnails
Post by: RikkiTikki on February 03, 2010, 09:58:41 am
i have done this already this is the printscreen of my config ??? (http://62.182.89.76/vmart_config.jpg)
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 03, 2010, 12:56:41 pm
Hi guys, i have the same problem too, after updating tables via sql, my new products thumbnail are regenerated well, but now, in the flypages my product thumb is the original size one! My previous thumb size was 150x150, i put it at 151x151, forcing the system to generate again my thumbs,so now i have in the "resized" folder, files with xxxxxxxx151x151.jpg name ???.What's happening? Thanks! :)
(GD working, and automatic resize checked on)
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 03, 2010, 19:29:21 pm
Well, frankly guys I'm not sure. It does seem like the thumbnail feature took a hit for the worse in the latest revision.
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 03, 2010, 22:24:51 pm
Ok Forrest, i'm not an sql guru, but i'm thinking about the sql query...
if you said that

"update jos_vm_product set product_thumb_image = product_full_image"

sets the product_thumb_image to the product_full_image, maybe we can revert the situation setting back the original settings again,so that we can point to the new generated thumbs correctly, am i wrong?

"update jos_vm_product set product_thumb_image = product_thumb_image" sure will not work,maybe we need a "temp" table to do the "swap"?

Just thinking loudly...any ideas?
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 03, 2010, 22:47:36 pm
No that won't work. Here what's should/typically happens.

1. You add a product/category photo.

2. If you have checked auto-generate thumbnail in the cat/prod folder when adding the photo, it will generate a thumb based on the size params in your config... such as 150x150. So the system adds two images.
   a. The full image in /products/xxxx.jpg
   b. The auto-gen thumb image in /products/xxxx_150x150.jpg

3. Then if you turn on the GD system, it should rebuild again the thumbnails, from the product_thumb_image, into a folder called /products/resized/xxxx_150x150.jpg


So why rebuild the thumbnails (not rezised, but actual thumbnail product_thumb_image) using "update jos_vm_product set product_thumb_image = product_full_image"?
Typically you would do this to have your GD library rebuild the RESIZED folder images. You would most likely chose to do this if your product thumb image is 150x150 but you have decided to change the size of your thumbnails to say 250x250.

Since the GD library is using the product_thumb_image to generate new 250x250 images, the images come out bad. Why? Becuase when you first added photos you had it set to 150x150, so the GD library is using a smaller image and trying to BLOW IT UP LARGER.

So what we did was set the product_thumb_images EQUAL to the product_full_image so when the GD library made new 250x250 images in the resized folder, it use the full_image, which is now also the thumb image in the database.


I hope this provides a better understanding of Product_full, Product_thumb, and RESIZED. The problem is that the code for some reason is not pulling form your resized folder, or your gd library is not working to create your resized images, which you can check in your resized folder.

About the only way to revert back to what you had is to
1. Know what your previous resize setting was. (you can check by looking in your product folder! The images are still there)
2. If it was 150 x 150 then you could do something in php to execute a command that replaces xxxx.jpg with xxxx_150x150.jpg for all product thumb images in your database table column product_thumb_image.


I would not do this first. I would
1. Back up my resized folder, then delete it!
2. Browse my website so it forces the GD library to rebuild the thumbs on the fly according to my GD settings... say 250x250.
3. Check my new resized folder to see if the GD library is working and creating 250x250 images for each product.
4. Clear my cache.
5. Revisit my site and see if the code is now pulling from my resized folder.
/product/resized/xxxx_250x250.jpg

Good luck! I will say I have not encountered problems with this until 1.1.4.. something is not kosher. :(
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 03, 2010, 23:03:37 pm
Got it, just now i'm trying to put my old thumbs on (i back'd up  ;)), i'll let you know what happens.

Quote
If it was 150 x 150 then you could do something in php to execute a command that replaces xxxx.jpg with xxxx_150x150.jpg for all product thumb images in your database table column product_thumb_image.

Yeah, same idea!I think i'll need some sql night session  ::)

For now,thanks friend!
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 04, 2010, 00:26:46 am
Bingo!!! ;D
No matter how you delete/recreate thumbs, the problem it's in the database,
if you look in the "jos_vm_product" table, the images path it's store without the "resized/" initial path,that's why flypages goes on pointing the originally-sized images.I looked on a previous backed up database and matched.I tried changing a pair of them, and worked nice.Maybe a bug? Dunno.
Now....what for adding the "resized/" part before the path for all of them?

You're right, something's not kosher  8)
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 04, 2010, 01:07:53 am
Well actually, the database should not have resized/ in it. This is becuase, the thumb is stored in the Product folder.

Again:
product/xxxx.jpg = full
product/xxxx_150x150.jpg = thumb

what get puts in the RESIZED FOLDER is the dynamic GD library builds. The reason it is a problem with the code is that...

1. If you have GD library on it will create:
product/resized/xxxx_150x150.jpg (= GD thumb)
from
product/xxxx_150x150.jpg (= original thumb when adding product image)

2. This only happens dynamically! Which means these images are created when you visit the category for the first time when the product image resized. This is NOT a database entry. the database will still say product/xxxx_150x150.jpg for product_thumb_image.

3. THE !!!CODE!!! as you entry a category should do this:
IF GD LIBRARY ON
THEN LOOK TO SEE IF IMAGE IS IN RESIZED FOLDER
IF IN RESIZED FOLDER USE THAT!
IF NOT IN FOLDER THEN CREATE ONE.

My problem is that the GD library is ON, the GD system is creating the thumbs, but the resized thumbs are NOT BEING USED!

Again the code is not using the databse thumb entry when GD is on, but rather checking to see if the image is in existence in RESIZED folder, and if it is then use it, and if it's not, then create one from the product_thumb_image and put it in resized folder.

If GD library is not on, then the system will just use the product_thumb_image that is in the database, which seems to be your problem as well! It's acting like the GD library is off and is only using the database entry, and not checking to see if an image exists in the RESIZED folder to use.

Now I have looked into this some, and have found a 00 appended to my src, which is not correct, and have posted a fix to this, but there is still something else in the checking of the image that is failing.

:(
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 04, 2010, 01:32:19 am
Forrest i understand the thumb generation mechanism,but like you can't understand why it's generating thumbs but it's don't using them...i'll keep on brainstorming...we have exactly the same problem.

look here
http://www.ideeriflesse.it/catalogo-prodotti?page=shop.product_details&flypage=flypage_images.tpl&product_id=24&category_id=14

the image location is
http://www.ideeriflesse.it/components/com_virtuemart/shop_image/product/resized/Fungo_4af87b98e7a9f_150x150.jpg, so it added correctly the "150x150" in the thumb name.

and the image link is
http://www.ideeriflesse.it/components/com_virtuemart/shop_image/product/Fungo_4af87b98e7a9f.jpg   ...the full sized one.

I made a test product, named..."test", everything works ok for new products.
I noticed that the "more images" thumbs of the old products are NOT affected by this,maybe this helps? Regards.



Title: Re: Rebuild Thumbnails
Post by: Forrest on February 04, 2010, 01:57:00 am
If you want to poke around... check out

administrator/components/com_virtuemart/html/shop.product_details.php
administrator/components/com_virtuemart/html/shop.browse.php

administrator/components/com_virtuemart/classes/ps_product
administrator/components/com_virtuemart/classes/ps_category

The problem likely doesn't reside there tho.
But most likey here:

administrator/components/com_virtuemart/classes/htmlTools.class.php
administrator/components/com_virtuemart/classes/imageTools.class.php

I hacked the htmlTools or imageTools to solve my problem in a rough way, but at this point I don't recall where or which file... though I think it was
administrator/components/com_virtuemart/classes/htmlTools.class.php

I just removed an if statement, from my recollection, as the function began to check image dimension.
Title: Re: Rebuild Thumbnails
Post by: linux4me on February 04, 2010, 19:29:28 pm
I was having the same problem after an upgrade from 1.1.3 to 1.1.4, but found that new category images that I added as a test in 1.1.4 did have the "resized/" prepended to the path name for the thumbs in the database.

I ended up fixing the problem--at least temporarily--as I described in this post (http://forum.virtuemart.net/index.php?topic=66039.msg218643#msg218643) using some SQL queries with phpMyAdmin, but as you can see in that thread it didn't appear to work for the OP.

I agree that the problem must lie in the code somewhere, as I don't believe the 1.1.3 -> 1.1.4 upgrade altered anything in the database. I'm going to look around later and see if I might have copies of the files listed above from a 1.1.3 installation, but I don't think I do. If someone still has a copy of the 1.1.3 PHP files that might be responsible and can post them, I can do a quick file comparison with the 1.1.4 versions to see what might have changed and we may be able to get to the bottom of this...
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 04, 2010, 19:57:47 pm
All good catch linux4me. The rabbit hole gets deeper....
Title: Re: Rebuild Thumbnails
Post by: linux4me on February 04, 2010, 22:50:43 pm
I found the file that appears to be causing the problem, thanks to Forrest.

First, I ran the SQL statement to reset all my thumbnail image paths to the full image path, removing the "resized/" I had added via phpMyAdmin to work around the issue. Then, I went through the list of possible files Forrest suggested as the cause one at a time and replaced the one on the server with an older version which I think is from 1.1.3.

The culprit turned out to be:
Quote
administrator/components/com_virtuemart/classes/ps_product

Replacing version 1948 2009-09-30 with version 1599 2009-01-08 seems to fix the problem; the thumbnails are re-created in the "resized" folder as they should be. I haven't found any issues using the old file creates. I have attached a copy of the ps_product.php that's working in a zip file in case anyone wants to try it.



[attachment cleanup by admin]
Title: Re: Rebuild Thumbnails
Post by: linux4me on February 04, 2010, 23:14:12 pm
You aren't going to believe this!

I have been playing with the 1.1.4 version of administrator / components / com_virtuemart / classes / ps_product.php to see if I could find the change in the code that was causing us such headaches.

On line 1364, the 1.1.4 version reads like this with an 'and':
Code: [Select]
if(PSHOP_IMG_RESIZE_ENABLE == '1' && $resize==1) {The file I used that fixed the problem with the thumbnails has an 'or' in the same location:
Code: [Select]
if(PSHOP_IMG_RESIZE_ENABLE == '1' || $resize==1) {I substituted the 'or' for the 'and' and low and behold, it worked! The thumbnails are showing up without the need for the "resized/" workaround in the database.

I haven't found any other issues yet. It would be great if someone else could give it a try.

This also fixed my problem with the full-sized images showing up for categories and products in the back end.
Title: Re: Rebuild Thumbnails
Post by: Forrest on February 04, 2010, 23:33:03 pm
I'll check it out tonight! Nice find linux4me. You're a stud.

Funny... so I checked it out, and that is where I had commented out some functioning... including the if statement... I just never caught the difference between || and &&.

Having found that, there is still a problem with my system. While it solves what has been addressed here, I still have the problem of the system very randomly choosing to use, or not, the resized image vs the product_thumb_image.

I'm at a loss, but it works well either way in my case, so it's not that big of deal.

Linux4me, I'd say you nailed it. Kuddos!
Title: Re: Rebuild Thumbnails
Post by: n3m3sys on February 05, 2010, 01:21:50 am
Bravo linux, ha funzionato alla grande!

Worked like a charm!!!
I think it may be considered [SOLVED],thanks to linux4me! :D :D
Title: Re: Rebuild Thumbnails
Post by: copperwire on May 22, 2010, 11:51:12 am
I registered just so I could say THANK YOU to linux4me. It was such a big relief to get it fixed with that little edit!
Title: Re: Rebuild Thumbnails
Post by: publipoint on June 23, 2010, 19:24:14 pm
Same situation here. Everything is fine in the category, but once I reach a product image...well...the image is full.
Title: Re: Rebuild Thumbnails
Post by: da_mascus on July 21, 2010, 18:58:54 pm
2. sql: update jos_vm_product set product_thumb_image = product_full_image

hey guys.
is there a way how to reverse this command?
After I used it to make the thumbnails, my product flypage starterd using the original picture as a thumbnail image. look at the pic if you like:
http://sw33t.sk/ukazka.jpg

thanks in advance
Title: Re: Rebuild Thumbnails
Post by: PRO on July 21, 2010, 19:34:16 pm
da_mascus are you saying you dont have a small image anymore?

Do you have dynamic resize enabled?
Title: Re: Rebuild Thumbnails
Post by: da_mascus on July 21, 2010, 20:12:07 pm
yop, it is enabled. the permissions are fine, even the thumbs in the folder are the right size.

but since I used that command in phpMyadmin, every product detail page started using the full size image instead of the thumbnail one.

btw this is the piece of code that shows the thumb inage in my flypage layout.

Code: [Select]
<div class="primage"> <?php echo $product_image ?><br/>
                    </div>

maybe my flypage is using a wrong VM variable ?


bottom line: is there a way how to reverse the command ?
Title: Re: Rebuild Thumbnails
Post by: PRO on July 21, 2010, 22:43:10 pm
no it cant.

BUT, if you have a recent CSV import with the thumb image url, you can upload it again.

but, THIS HAS TO BE A SIMPLE FIX.
Title: Re: Rebuild Thumbnails
Post by: JOOblogs on August 18, 2010, 07:12:53 am
1. By default VM use resized image for GD render . So in case resized image have smaller size than GD re-resize unuseful !
GD function should take org image for resize not resized image.
2. Solution
+ Delete all images in resized folder.
+ Open file
administrator\components\com_virtuemart\html\shop.browse.php

Replace
Code: [Select]
        if( $db_browse->f("product_thumb_image") ) {
            $product_thumb_image = $db_browse->f("product_thumb_image");
}
else {
if( $product_parent_id != 0 ) {
$product_thumb_image = $dbp->f("product_thumb_image"); // Use product_thumb_image from Parent Product
}
else {
$product_thumb_image = 0;
}
}
by
Code: [Select]
        if( $db_browse->f("product_thumb_image") ) {
            $product_thumb_image = $db_browse->f("product_full_image");
}
else {
if( $product_parent_id != 0 ) {
$product_thumb_image = $dbp->f("product_full_image"); // Use product_thumb_image from Parent Product
}
else {
$product_thumb_image = 0;
}
}

Above code will allow use full size image for GD resize without resized image that stored in db !
So if you dont have any require with resized image stored in db. You can try above code.
I have used this code for my client.
Title: Re: Rebuild Thumbnails
Post by: LeonZ on February 08, 2011, 10:31:03 am
I was having these problems also. Wanted to have a productrow of 2 on my categorie page but not knowing what to put into the GD size so the categorie page looks good.

For testing I altered the browse page and gave in a product_thumb width.
for my browse_2.php the code was
Code: [Select]
          <?php echo ps_product::image_tagurldecode($product_thumb_image), 'class="browseProductImage" border="0" title="'.$product_name.'" alt="'.$product_name .'"' ?>and I changed it to
Code: [Select]
          <?php echo ps_product::image_tagurldecode($product_thumb_image), 'class="browseProductImage" border="0" width="112" title="'.$product_name.'" alt="'.$product_name .'"' ?>This way I was able to find out the exact size of my thumb so I didn't have to loop through all steps over and over till everything suited my needs and looked fine.

ofcourse if you want your thumb just a little smaller this can be a nice temporarily workaround.

Title: Re: Rebuild Thumbnails
Post by: smitha.i21 on March 27, 2011, 04:31:26 am
Hi Guys

I was trying to resize my thumbnails on my site, and I used the below sql code, which then made ALL my thumbnails FULLSIZE

"update jos_vm_product set product_thumb_image = product_full_image"

Also, my 'resized' folder is now empty.
(/public_html/components/com_virtuemart/shop_image/product/resized)

QUESTION: Can I set the exact size of my thumbnails on my product list page?

QUESTION: Can I have two differnt thumbnail sizes? One size for the product list page where it shows all products, and another thumbnail size for the product details page?

I have looked at a gazillion forums and tried everything, and nothing is working for me :(

Please help, my site looks ridicolous with full size thumbnails all over it :\


Title: Re: Rebuild Thumbnails
Post by: WinTeX on November 30, 2011, 19:11:16 pm
Seroiusly, so complicated for me. How can be that hard to set the +++obsecenity removed+++  images to the size that I want oh my lord!

Mod edit: bad language is not permitted in this forum.
Title: Re: Rebuild Thumbnails
Post by: zigsdesign on January 13, 2012, 21:10:03 pm
I have been going nuts trying to figure out this issue. I did the SQL command in the first post of this thread and that worked fine but the thumbnails were not displaying in the browse page, related products, etc. I figured out the issue. It was in the show_image_in_imgtag.php file. There is a call to the Joomla configuration file which I had moved outside the the root web folder. Once I moved it back into the root web folder, everything worked fine!
Title: Re: Rebuild Thumbnails
Post by: cte2087 on April 05, 2012, 23:22:59 pm
I am still running Joomla 1.5.18 with a Virturemart build of 1.1.4. I have auto thumb creation turned on for product images. I have the thumbnail auto-generating with the main product image. I have also added additional images to the products and they display on the fly page, but they appear the same size as the category/global thumb. I need them to be even smaller on the flyout page and I cannot for the life of me get the "resize" to work in the media pop-up when adding the additional images.What am I missing?

I have read numerous threads on problems that sound similar, but none of the solutions seem to work. Does anyone have a suggestion/solutions that is proven to work? Virtuemart....have you addressed this issue somewhere that I can read and make the adjustment? Do I need to upgrade the client's WHOLE site?

Thanks,
CTE2087
Title: Re: Rebuild Thumbnails
Post by: remico on November 13, 2013, 13:00:55 pm
Anyone interested in a solution for this? I have one without hacking core files. Only SQL!  (J1.5.26 VM 1..1.9)

- First empty the resized folder (this will force GD to recreate)
- Then run this SQL: update jos_vm_product set product_thumb_image = product_full_image
- Browse to all your categories to force thumbnail recreation (you'll see the generated thumnails in te resized folder).
- After all categories are browsed run this SQL: update jos_vm_product set product_thumb_image = concat('resized/',substring(product_full_image,1,length(product_full_image)-4), '_120x120.jpg') *

Now you have new thumbnails based on the full images!

* change '120x120' if you have other dimensions set in VM Dynamic thumbnail generation. You could also add a test product to see the filename in the resized folder.
Title: Re: Rebuild Thumbnails
Post by: Forrest on December 11, 2013, 00:33:44 am
Yep, I can confirm remico's fix does do it. I did this long ago and forgot to update.
Further, I've added to this code to check for existing thumbs and product a non-dynamic link for these images processed by ps_product->image_tag. Anyone still on 1.1 and interested, I can go further into detail.
I've also made it so the code works for specifying new dimensions in template files, rather than just in the admin settings, for rebuild, thus if anyone is not happy with just one size of thumb, it will allot for the rebuild any number of custom sizes specified.