We had a case where image files needed to manipulated based on the given image style uri. I found out there's no way hooking into the process of image style flow. What I end up doing was to define a preprocess hook in image_style_deliver() and implement the hook in my site specific custom module. This might be useful for someone else too.

Patch to followed.

Comments

TomiMikola created an issue. See original summary.

tomimikola’s picture

Status: Active » Needs review
StatusFileSize
new562 bytes

Here's the patch.

Implement the hook in your custom module like this:

/**
 * Implements hook_image_style_deliver_preprocess().
 */
function MYMODULE_image_style_deliver_preprocess($image_uri) {
  /* Your magic manipulations here ...
      e.g.
      if (!is_file($image_uri)) {
        // File is not found in files storage, copy it from master storage
        file_unmanaged_copy($masterloc, $image_uri, FILE_EXISTS_ERROR);
      }
  */
}

Status: Needs review » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.