Proposal to add alter after imagecache_external_fetch in imagecache_external.module

Created on 3 March 2025, about 1 month ago

Currently, the imagecache_external module allows fetching images from external sources, but there is no simple way for developers to customize this process after the imagecache_external_fetch function (line 166 in imagecache_external.module) is executed.

I propose adding an alter hook by calling \Drupal::moduleHandler()->alter('imagecache_external_fetch', $filepath); immediately after this function call, so developers can modify the behavior or parameters of image fetching, such as adjusting the file path or adding custom logic.

Example of modified code:

    elseif ($filepath = imagecache_external_fetch($url, $directory . '/' . $filename)) {
      \Drupal::moduleHandler()->alter('imagecache_external_fetch', $filepath);
      return $filepath;
    }

Why would this be useful?:
This would allow developers to easily hook into the image-fetching process and modify aspects such as the file path, add transformations, or apply additional logic (e.g., security checks or image transformations) before the image is saved or used.

It would enhance the flexibility of the module and allow for customized behavior without modifying the core module code.

Feature request
Status

Active

Version

3.0

Component

Code

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024