2

According this bug issue, hook_file_download is called twice when private style image is requested. The first time is requested original image without style and then the style image is called. Is there any workaround to skip checking access of original image?

In particular, I have a website, where user can share his private images on his facebook account. Then I need to allow facebook to send http request to download image. The problem is, that facebook hs limitations on size of images. Facebook doeasn't accept larger images when downloading thumbnails from my website. As I tested it, although my image thumbnails are small, drupal system check access against large original image so facebook doesn't accept the thumbnail.

Is there any workaround, how could I solve this problem?

thanks for advice Tomas

1

Disclaimer - Use this method at your own risk, it has security implications if you don't set up and test it properly :)

A quick and dirty way to override that functionality would be to implement hook_module_implements_alter(), remove the image module's implementation of hook_file_download(), and then implement your own version which has the desired logic. e.g.

function MYMODULE_module_implements_alter(&$implementations, $hook) {
  if ($hook == 'file_download') {
    unset($implementations['image']);
  }
}

function MYMODULE_file_download($uri) {
  // Copy the code from image_file_download() and alter as required.
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.