public function purgeImageCache()
{
$strTargetPath = \System::getContainer()->getParameter('contao.image.target_path');
// Walk through the subfolders
foreach (scan(TL_ROOT . '/' . $strTargetPath) as $dir) {
if (strncmp($dir, '.', 1) !== 0) {
$objFolder = new \Folder($strTargetPath . '/' . $dir);
$objFolder->purge();
}
}
// Also empty the page cache so there are no links to deleted images
$this->purgePageCache();
// Add a log entry
$this->log('Purged the image cache', __METHOD__, TL_CRON);
}