You are here

function imagecache_external_cron in Imagecache External 8

Same name and namespace in other branches
  1. 7.2 imagecache_external.module \imagecache_external_cron()

Implements hook_cron().

Periodically flush caches at configured frequency.

File

./imagecache_external.module, line 332
Allows the usage of Image Styles on external images.

Code

function imagecache_external_cron() {
  $last_cron_flush = \Drupal::state()
    ->get('imagecache_external.last_cron_flush', 0);
  $frequency = \Drupal::config('imagecache_external.settings')
    ->get('imagecache_external_cron_flush_frequency', 0);
  if ($frequency !== 0 && (\Drupal::time()
    ->getRequestTime() - $last_cron_flush) / (3600 * 24) >= $frequency) {
    if (imagecache_external_flush_cache()) {
      \Drupal::state()
        ->set('imagecache_external.last_cron_flush', \Drupal::time()
        ->getRequestTime());
    }
  }
}