Skip to content

Instantly share code, notes, and snippets.

@AlexHupe
Created September 10, 2020 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexHupe/5851560cc93496424c016f8eaa582d70 to your computer and use it in GitHub Desktop.
Save AlexHupe/5851560cc93496424c016f8eaa582d70 to your computer and use it in GitHub Desktop.
Oxid: delete older generated Pics
<?php
for ($i=1; $i<13; $i++) {
$masterPath = "../out/pictures/master/product/".$i."/";
$generatedPaths[] = "../out/pictures/generated/product/".$i."/100_100_99/";
$generatedPaths[] = "../out/pictures/generated/product/".$i."/370_259_99/";
$generatedPaths[] = "../out/pictures/generated/product/".$i."/565_400_99/";
$generatedPaths[] = "../out/pictures/generated/product/".$i."/1000_700_99/";
$allMasterPics = glob($masterPath."*.{jpg,JPG,jpeg,JPEG,png,PNG}", GLOB_BRACE);
$thistime = time();
foreach ($allMasterPics as $masterPic){
$masterFmtime = filemtime($masterPic);
if($masterFmtime > ($thistime - 72800)) { // Dateien der letzten 48h vergleichen
foreach ($generatedPaths as $genPath) {
$generatedPic = $genPath.basename($masterPic);
if (file_exists($generatedPic)) {
if (filemtime($generatedPic) < $masterFmtime) {
unlink($generatedPic);
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment