Skip to content
Snippets Groups Projects
Commit 441a2c81 authored by Michael Lee's avatar Michael Lee
Browse files

update opic cache hook to also flush image style when refreshing images

parent 601f6fbd
No related branches found
No related tags found
1 merge request!168update OPIC cache hook to also flush image style when refreshing images
......@@ -62,11 +62,15 @@ function imagecache_render_imagecache_external_needs_refresh_alter(&$needs_refre
date_default_timezone_set('America/New_York');
$current_hour = (int) date('G');
if ($current_hour >= 3 && $current_hour < 5) {
if (filemtime($filepath) < \Drupal::time()->getRequestTime() - 60 * 60 * 24 - (30 * 60)) {
$image_style_name = 'people_profile_image';
$image_style = \Drupal::entityTypeManager()->getStorage('image_style')->load($image_style_name);
if ($image_style && filemtime($filepath) < \Drupal::time()->getRequestTime() - 60 * 60 * 24 - (30 * 60)) {
\Drupal::logger('imagecache_external')->notice('@filepath older than 24 hours, refreshing', [
'@filepath' => $filepath,
]);
$needs_refresh = TRUE;
$image_uri = str_replace('public://', '', $filepath);
$image_style->flush($image_uri);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment