VirtueMart 1.1.x [ Old version - no longer supported ] > Frontend Modules VM 1.1

delete unused images script

(1/6) > >>

georgian:
To delete unused images in /components/com_virtuemart/shop_image/product  /resized works well. Remain the only images used.
If anyone knows how to implement like an administrative utility script ...

--- Code: ---<?php
// The files must have 0777 chmod permissions aswell as the directory that the file is stored in.

// the directory, where your images are stored

$imgdir = IMAGEPATH."product/";
// list of filetypes you
$allowed_types = array('png','jpg','jpeg','gif'); 

$dimg = opendir($imgdir);

while($imgfile = readdir($dimg))
{
if(in_array(strtolower(substr($imgfile,-3)),$allowed_types))
{
$db = new ps_DB;

$q = "SELECT product_full_image FROM #__{vm}_product WHERE product_full_image='$imgfile'";

$db->query( $q );
if ($db->num_rows()==0) {
echo $imgdir.$imgfile." </br>";
unlink($imgdir.$imgfile);
};
}
}
?>
--- End code ---

KooTjoo:
Hi,

I am also very interested in using this script. I can't get it working however. Did you manage to implement it in the admin area?

Thanks,
KooTjoo

georgian:
I insert this code into browse page (for testing).
I do not know how to insert in the administration page. Maybe others ...

positronio:
i have applied the above php script and it deletes unused product images but unfortunately it also deletes the products additional images. what shall i do to exclude from deleting additional images;

Gruz:
I've improved the solution. Not it doesn't remove additional images.

http://gruz.org.ua/en/about-joomla/34-virtuemart/27-vydalennja-zobrazhen-shcho-ne-vykorystovujutsja-z-virtuemart-11x.html

Navigation

[0] Message Index

[#] Next page

Go to full version