Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
As a result from issue #2262589: Add a maximum lifetime for a retrieved image I decided to add a hook so that other modules can decide whether or not the image should be re-fetched.
I also added some documentation on how to use it:
<?php
/**
* Add custom image refresh logic.
*
* Use this hook to add extra validation(s) whether to refresh images.
*/
function hook_imagecache_external_needs_refresh_alter(&$needs_refresh, $filepath) {
// Example: refresh images at least once a week.
if (filemtime($filepath) > REQUEST_TIME - 60 * 60 * 24 * 7) {
$needs_refresh = TRUE;
}
}
?>
Comment | File | Size | Author |
---|---|---|---|
#2 | added_hook_to_alter-2625294-2.patch | 2.22 KB | BarisW |
Comments
Comment #2
BarisW CreditAttribution: BarisW as a volunteer and at LimoenGroen commentedHere's a patch for reference. Already committed.