News:

Support the VirtueMart project and become a member

Main Menu

Bug in thumbnail dinamically resizing?

Started by baggeler, July 10, 2015, 15:29:16 PM

Previous topic - Next topic

baggeler


Seems like dinamically resizing of thumbnails is not working in subdirectory structure, is this correct?

Description:

Just updated VM to 3 and Joomla to latest 3.4.x.

I created a subdirectory structure to easily manage the large amount of product images into categories
In VM configuration set option to dinamically resize thumbnails

However thumbnails are only created for images/stories/virtuemart/products root folder, not for its subdirectories, is this correct? I guess this must be a bug, right? How can I force creation of thumbnails in subdirectories?

I found several discussions about this on old VM 1.1 but little to no useful information on 2.x/3.x , I assume the code/setting of dinamically resizing thumbnails must have been solved and its just a matter of proper configuration or script to run, right? But at me it does not work properly and I get lots of "disconnected" images...

________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

jjk

As far as I know VM can't generate thumbnails automatically in subdirectories other than the default image folder. There is no configuration option which tells VM in which folder it should place automatically generated thumbnails. I do use image subdirectories, too (50+), but probably use different subdirectory names and a different subdirectory structure and when I upload for example 20 new product images via ftp into different subfolders, VM would have to ask where I would like to store the thumbnail for each of them.

Therefore I've disabled automatic thumbnail creation and use my photo editing software to create the thumbnails. If you don't have one, there are some free photo editors which can batch-process images. However, if you upload the thumbnails into subdirectories also (like I do), you have to adjust the image path for each thumbnail in the 'Product Edit' view > 'Product Images' tab in order to make it visible.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

Studio 42

Hi,
perhaps, on adding resized folder in the subdirectory?

I only think it work because the thumb path is set so :
$file_url_thumb = $this->file_url_folder.'resized/'.$this->file_name_thumb.'.'.$this->file_extension;
Then if you have a subdirectory
.../product/subfolder
On adding a subfolder
.../product/subfolder/resized
the resizing function should find the good resized folder
But is say JJK, best is to use a batch image tool  to get better quality/compression for thumb
like pngquant : https://pngquant.org/.(you have gui for osx and windows
or check this post : https://www.raymond.cc/blog/4-free-tools-to-optimize-and-compress-png-images-without-loosing-quality/

I have resizing active, but time to time i use this type of tools to get better compression size, because this remove some header info and do multiple test to find best way to compress.
You can win 50% in size in some case and google like you ;)

Greets,
patrick Kohl

baggeler

Quote from: jjk on July 10, 2015, 20:40:42 PM
...There is no configuration option which tells VM in which folder it should place automatically generated thumbnails....
... VM would have to ask where I would like to store the thumbnail for each of them.

JJK,

In my view it would be the most simple solution for Virtuemart to by default create/use/look for a "resized" folder in each subdirectory. This way the application can use the same code (= current folder - subfolder "resized", iterate through all resized folders within products) to find the thumbnails.

In order to better understand VM logic, could someone put some light on following questions:


  • When looking up images available to link with products, will Virtuemart search for images or for thumbnails only? (See related question/test case here http://forum.virtuemart.net/index.php?topic=130716.0)
  • Assuming I would like to implement the solution above by asking a programmer to add the iteration, where would it need to be placed and could it be solved as override in order to avoid hack and keep VM clean for future updates?

Thanks for any insights,

Bernhard
________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

Studio 42

Hi baggeler,
DO you have try to add the resized folder in the subdirectory?

baggeler

I made following simple test case:


  • Withing images/stories/virtuemart/products I created  subfolder called "MySubFolderA"
  • I uploaded a picture by FTP called "MyNewProductImage" into this directory.
  • Within "MySubFolderA" I created another subdirectory "resized" and placed there a thumbnail image as "tn_MyNewProductImage"

Now, when trying to link this image to a new product, it does not appear.

Additionally executed the command "Reset thumbs" (from which I would expect that it would reset all thumbnails of any images within image directory products (and its subdirectories)

Still no image to appear in my image links / tumbs to link with products...

________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

Studio 42

Hi,
the thumbs creation use the size in the name in your case with default setings : tn_MyNewProductImage_0X90.EXT
Quote from: baggeler on July 12, 2015, 02:15:30 AM

  • Withing images/stories/virtuemart/products I created  subfolder called "MySubFolderA"
  • I uploaded a picture by FTP called "MyNewProductImage" into this directory.
  • Within "MySubFolderA" I created another subdirectory "resized" and placed there a thumbnail image as "tn_MyNewProductImage"


If you add manually the thumb path in the form, then virtuemart do not check if this exist.
Simply remove the thumb path and check if the thumb is generated.

baggeler

#7
Quote
the thumbs creation use the size in the name in your case with default setings : tn_MyNewProductImage_0X90.EXT
At which point are thumbs created by VM? By which routine? Is it "Reset thumbs" as I assume? I guess there is a bug in this routine and this is the point of my message here including the below test case to be able to test/reproduce to confim or not...

QuoteIf you add manually the thumb path in the form, then virtuemart do not check if this exist.
When does VM check existence of the thumb? 
I am not adding thumb path in form, I am only making the steps exactly as described in test case below, i.e. upoading file into subdirectory and - as suggested by . Is anybody able to reproduce and confirm or has other result?

Allow me to better understand the process as I am not deep enough to analyze the php code in detail, so if someone could shed some light on following questions so I can understand if situation I have is a bug or just normal behaviour of VM:

The images/thumbs shown in "Search for images" in Product Configuration, what is this routine searching for (images or tumbnails?) and where (only product directory or including subdirectories?)

I assume the images shown in this "Search for images" to be the thumbnails found as sometimes it does show a filename but no thumbnail associated. What would be a typical case, by the code - assuming my test case - should it or should it not show any image and/or tumbnail?
Currently at my testcase below, VM seems neither to find the image nor its thumbnail (at least as far as I can see). If someone reproduces, please confirm as I first need to know for sure if the behaviour is by design (in this case need to look for other solution or have somebody program what I want) or a bug.

Thanks in advance
________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

baggeler

#8
Digging into database I now understand that all media in VM needs first to be in table "virtuemart_medias" before beeing able to be recognized by VM in the product search, is this correct?

I see that neither the routine "Syncronize Media do Virtuemart" nor "Reset thumbs" will either create my thumbs for images in my testcase of "MySubdirectoryA" nor find any images in any subdirectories of products and create a correct entry into this media database, is this correct? Still the big question is this by design or bug?

If anybody using subdirectories in his products folder could please give me some hints how he solved this situation?

I guess that if I upload thumbs into each subdirectory into "resized" folder I may ask someone to create a script which would iterate throug the subfolders and add these records into the table "virtuemart_medias". Would this be the best solution? Any other suggestion?

Modified:
In my testcase below I now even added manually a record to have the full image and the thumbnail path as record in table "virtuemart_medias" hoping this to be way to go in order to VM recognize the image in "Search for images". Unfortunately this is not the case. Still, the image does not appear in selection and I dont have any way to link the image. To me this appears to definitely be a bug now until somebody can confirm the test case is working correctly for him.


Kind regards,
Bernhard
________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

Studio 42

I think vm has simply not the feature to handel correctly subfolders, it's very strange this not work because the code seems to check the good path.
I don't have time to check all now, but i think, this don't need many code changes.

baggeler

Studio 42 - or anyone else - could you help me identify the correct file where the code need to be changed?

I have a hard time to identify the correct place/file and would like to pass this to somebody fix. I am sure this must be just a few lines of code to add subdirectory iteration and as soon as I have fixed I can place the final code here so the VM team can include this in their next release if they want.

If anybody could contribute the smallest help on any of the questions below it would help a lot to identify and specify the correct changes as those questions below are not yet clear. Thanks in advance for anyones help.


Just for information on those which may come across this same problem and searching in the forum, I found the following relevant threads, all unclear or unsolved regarding the mentionned issues (most others are irrelevant as 1.1 related as far as I can see, if anyone knows about a thread with any solution which would contribute, please post here):

https://forum.virtuemart.net/index.php?topic=115516.0
https://forum.virtuemart.net/index.php?topic=126139.0
________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

Studio 42

If you have time :
media upload, check ...
YOURSITE\administrator\components\com_virtuemart\helpers\mediahandler.php
file for resizing image is
YOURSITE\administrator\components\com_virtuemart\helpers\img2thumb.php
But check with max(milbo), i'm not sure he want change anything because he had many trouble to do it work.

Milbo

It works for me in vm3. The trouble was to make it that way

...\VM3j2\images\stories\virtuemart\product\
...\VM3j2\images\stories\virtuemart\product\subfolder
=>
...\VM3j2\images\stories\virtuemart\product\resized
...\VM3j2\images\stories\virtuemart\product\resized\subfolder

But it does NOT work for files for sale
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

baggeler

Thanks Milbo,

After testing further, I understand the current designed process of uploading images into subdirectories needs to be exactly:

1) Upload original images in products/Mysubfolderstructure
2) Upload resized images in products/resized/MySubFolderStructure
3) Execute "Syncronize Media to VM" button in order to VM recognize the above images and make available to link to products.

I also understand that whenever "Recreate thumbs" button is pressed I would loose ALL images placed within the resized folder

I worked through several test cases and some of them are still confusing to me as it seems not clear yet where and under which conditions/exact criteria the product detail image linking tab (Seach for images) is grabbing its thumbs and under which conditions this procedure is offering an image to link however with no image/thumb available like in screenshot attached.

As I can't write and only hardly read php code I did not have this source to check and hope somebody knowing the code could be more specific on this.



________________________________________
The more I know the more I know I don´t know
Socrates

Site: www.orgonite-brasil.com
Tech: Joomla 3.7.3,  Virtuemart 3.2

Milbo

It is "relativly" simple if you know my coding patterns:
Defaults are not stored per item.

you dont need to upload your thumbs, if you use the dynamic creation. The thumbs are generated on the fly.

You can override the default path of your thumb and use another one.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/