Author Topic: Product Images - Clean up unused images ?  (Read 3275 times)

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Product Images - Clean up unused images ?
« on: May 16, 2016, 13:54:43 pm »
Hi,

I have many files in my public_html/images/stories/virtuemart/product/ directory and I am looking for solutions to solve this problem.

1) Is there a utility to clean up (remove or copy elsewhere) all images that are not being used?

2) Is there a way to organize images ?  eg have sub-directories under public_html/images/stories/virtuemart/product/ for each manufacturer ?  this would make each sub-dir much more manageable.

Thanks

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1022
    • Kreativ Fotografi
  • VirtueMart Version: 3.0.19.9
Re: Product Images - Clean up unused images ?
« Reply #1 on: May 16, 2016, 15:02:00 pm »
Hello

Yes this is possible. I arrange all my images in that way. The only problem is the upload of images. Using the media tools for Joomla or ftp solves that somehow. The next step is kind of awkward, You can use syncronize media in VM Tools. And then assign the syncronized items to Your products and change the description for the items that are found during syncronization.

I don´t know of any cleaning tool. But as You say this helps making everything more easy to manage.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.6.5
Virtuemart 3.0.19.9
Olympiantheme Hera (customized)

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Re: Product Images - Clean up unused images ?
« Reply #2 on: May 16, 2016, 15:49:53 pm »
Thank you for your reply.

I upload images via FTP, so that is not a problem.
I upload products via CSVI, so I guess that I will have to edit the template each time and set the "Location product files " to the "images/stories/virtuemart/product/manufacture_1" directory.  This is a pain, but not that big a deal.

I do not understand the rest of the procedure.  Is there documentation somewhere that I can read more.  The VM documentation has a paragraph that explains it, but it is still not clear to me.

Thanks

GJC Web Design

  • 3rd party VirtueMart Developer
  • Super Hero
  • *
  • Posts: 7527
  • Virtuemart, Joomla & php developer
    • GJC Web Design
  • VirtueMart Version: 2.6.22 & 3.2.2
Re: Product Images - Clean up unused images ?
« Reply #3 on: May 16, 2016, 16:38:53 pm »
I use the attached script to clean up unused images.. it was from a vm1.1. version I think..

just unzip and upload to the root and call from the browser..  www.xxx.com/vm_img_remove.php  - back up first!!!
use at your own risk

in the file you can target products or cats

GJC Web Design
VirtueMart and Joomla Developers - php developers http://www.gjcwebdesign.com
VM3 AusPost Shipping Plugin - e-go Shipping Plugin - VM3 Postcode Shipping Plugin - Radius Shipping Plugin - VM3 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
http://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1022
    • Kreativ Fotografi
  • VirtueMart Version: 3.0.19.9
Re: Product Images - Clean up unused images ?
« Reply #4 on: May 17, 2016, 08:29:37 am »
Sorry  :-[

This is not really clear I know.

Go into Product images and use search images. Writing for example cap in the search for images box is equal to a search for the unique filename identifier *cap*  (n.b this does not have to be the same as the filename on disk).

You will see up to 16 images, choose the right image or press + for the next 16 images. Then click on the edit image iformation Icon on the image You selected and edit as You wish.

regards

Jörgen @ Kreativ Fotografi
Joomla 3.6.5
Virtuemart 3.0.19.9
Olympiantheme Hera (customized)

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Re: Product Images - Clean up unused images ?
« Reply #5 on: May 17, 2016, 09:01:05 am »
Thanks.

I have thousands of images. This is not something that I want to do manually, image by image.

I will need a way to tell the database where everything is.

Ghost

  • Jr. Member
  • **
  • Posts: 341
Re: Product Images - Clean up unused images ?
« Reply #6 on: May 17, 2016, 09:10:17 am »
http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm

There is this plugin. If you get an error, add this line to vmmedia_clear.php file:

Code: [Select]
jimport('joomla.filesystem.file');

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Re: Product Images - Clean up unused images ?
« Reply #7 on: May 17, 2016, 11:11:12 am »
Jorgen, (sorry no ubshlang on my keyboard)

VM has a  section in configuration/templates for Media File Settings where your set the "images/stories/virtuemart/product/"

If I upload the images to the images/stories/virtuemart/product/man1/ directory and use CSVI to import the product and tell it that the image is there, will it know to create the thumbnail in
images/stories/virtuemart/product/man1/resized ? and will VM know to find it there to display it ?

Shimon

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2182
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Product Images - Clean up unused images ?
« Reply #8 on: May 17, 2016, 11:11:47 am »
There is this plugin. If you get an error, add this line to vmmedia_clear.php file:
Code: [Select]
jimport('joomla.filesystem.file');
Hi Ghost,
I really appreciate when someone report me a bug ;)
Patrick

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Re: Product Images - Clean up unused images ?
« Reply #9 on: May 17, 2016, 11:15:18 am »
Patrick,

What do the two buttons do?

Clear - I assume clears the images that are not used.  I would actually prefer to move them to "recycle" directory
Error - ?? What does Error do ?

Shimon

Jörgen

  • Global Moderator
  • Full Member
  • *
  • Posts: 1022
    • Kreativ Fotografi
  • VirtueMart Version: 3.0.19.9
Re: Product Images - Clean up unused images ?
« Reply #10 on: May 17, 2016, 11:47:52 am »
Hi Shimon

Have seen this extension:
http://shop.ekerner.com/index.php/shop/joomla-extensions/com-vmproductscsv-detail

I seems to be able to add images and make the media items neccessary if they are uploaded to You site. Other URL's than the standard Products can be used and You don´t have to syncronize medias through Virtuemart

regards

Jörgen @ Kreativ Fotografi
Joomla 3.6.5
Virtuemart 3.0.19.9
Olympiantheme Hera (customized)

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2182
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Product Images - Clean up unused images ?
« Reply #11 on: May 17, 2016, 11:52:26 am »
The problem is that i use Joomla core function and this are in some case not loaded. So i need to add it.
1 button remove images : difference from images in folder and DB (unused files).
1 button remove DB entries : inexisting files.
If you need a "recycle" directory, best is to do a backup before using the tool(or zip all your images). The tool is only here to clean all bugs in db and all unused files.
Regards,
Patrick

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2182
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Product Images - Clean up unused images ?
« Reply #12 on: May 17, 2016, 12:11:31 pm »
Updated file for http://shop.st42.fr/en/products/virtuemart-media-folder-clear.htm
So now Joomla library is not missing.

Shimon Hirschhorn

  • Jr. Member
  • **
  • Posts: 141
Re: Product Images - Clean up unused images ?
« Reply #13 on: May 17, 2016, 13:01:07 pm »
Patrick,

I like the first part : Getting rid of files that are cluttering up the product images directory.

As far as deleting non-existent images from the DB, I don't like this.  I would rather have a list of missing images ( and the products that they belong to) so that I can find them and upload them.

Shimon

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10272
  • VirtueMart Version: 3+
Re: Product Images - Clean up unused images ?
« Reply #14 on: May 17, 2016, 13:34:14 pm »
I wrote this to find images not assigned to products


<?php function fullmedia(){
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__virtuemart_medias'));
$db->setQuery($query);
$rows=$db->loadAssocList();
$html='';
foreach ($rows as $row){
$mid=$row['virtuemart_media_id'];
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->quoteName('#__virtuemart_product_medias'));
$query->where($db->quoteName('virtuemart_media_id')." = ".$db->quote($mid));
$db->setQuery($query);
$row2 =$db->loadAssocList();
if (empty($row2)){
$html.=$mid.'<br/>';
}
}
return $html;


}
?>
<?php echo fullmedia();?>
I do NOT do development work for hire.