Hello,

I love the idea of this module and would really like to see it developed further for D7. I've attached a patch with some suggestions. The patch is against commit f79573b5b2e4ef48f32991e1385988f3ccc77e7b .

This is just a crude patch to get the module working. I've not looked at imagecache. Not sure whether the drupal_goto() I've added is a good idea or not, but it seems to work and possibly gets round your mimetype issue.

I'd also recommend adding something to the README about 404_fast_paths. In newer versions of D7 (I'm testing this on 7.10), there are $conf values in settings.php that cause requests to non-existent files to skip Drupal altogether. I think these need to be commented out before your module will work.

Thanks!

CommentFileSizeAuthor
file_defer.patch1.5 KBbillspreston

Comments

ronan’s picture

Thanks for the interest. Can you explain what issues your patch is trying to address? I'm having a hard time parsing the difference mentally (other than the redirect).

Thanks again
Ronan

billspreston’s picture

Hello,

Sure - changes listed in order.

1)

- $items[$directory_path . '/%image_path'] = array(
+ $items[$directory_path] = array(

I could be wrong, but I don't think "%image_path" is necessary. According to http://api.drupal.org/api/drupal/modules--system--system.api.php/functio... , it looks like you can use % to refer to different callbacks according to argument, but this isn't what you want here - you always want the callback to be file_defer_getfile .

2)

- $directory = file_stream_wrapper_get_instance_by_scheme($scheme)->getDirectoryPath();
+ $directory = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();

I forget what value $scheme was getting, but it wasn't 'public'. You've already limited yourself to using the public:// stream earlier in your code, so why not specify it here too?

3)

- $img = rtrim($url, "/") . '/' . $directory . '/' . $filepath;
+ $img = rtrim($url, "/") . '/' . $filepath;

Let's say we look for http://sitewithoutafile.com/sites/default/files/image.jpg, which is missing. It's available at http://sitewithafile.com/sites/default/files/image.jpg . We add "http://sitewithatile.com/sites/default/files/" in our config, and it passes into $url. The original code above will try and download the file from http://sitewithafile.com/sites/default/files/sites/default/files/image.jpg (More simply, $directory is part of the URI on the local machine, so there's no reason to put it an external URI)

Hope that makes sense.

billspreston’s picture

Also, with issue 1) above: It works with my change and it doesn't work without it!

fmitchell’s picture

I can confirm that the patch in #1 works on my D7 site. The module does not work without it.