I was having a problem using this with cloudfront and the correct imagecache preset filename. Instead of trying to recreate the filename in cloudfront and since this modules ties into imagecache I figure it was safe to use the imagecache function.

I have attached a patch that worked for me in case it helps others.

This is the first patch I have added so please let me know if I could have done something better.

Comments

doublejosh’s picture

The issue being solved here seems to dance around something I'd like to have control over.

Images are pushed to AS3 named like:
"http://img.mydomain.com/preset_19/filename.png"
rather than
"http://img.mydomain.com/sites/default/files/imagecache/product_thumbnail/filename.png"
or maybe just
"http://img.mydomain.com/product_thumbnail/filename.png"

Suggestions since you're in the area?

anantagati’s picture

StatusFileSize
new890 bytes

I had problem with patching.

So I changed manually
$imagecache_path = file_directory_path() .'/imagecache/'. $imagecache_namespace .'/'. basename($path);
to
$imagecache_path = imagecache_create_path($preset_info['presetname'],$path);
as it was in your patch and it works good.

kmonty’s picture

Title: Problem matching the imagecache preset filename » Image path is not set to the CDN if using subdirectories within the "files" directory
Priority: Normal » Critical

In my case, profile photos are placed in sites/all/files/profile and the basename() function strips out the "profile" folder from the "original_file_path" that is stored in the {cloudfront_files} DB. This patch fixes that.

We shouldn't need the module_exists() check though, since Imagecache is a dependency of Cloudfront.module

kmonty’s picture

Status: Needs review » Reviewed & tested by the community
BenK’s picture

Subscribing...

tnichols’s picture

StatusFileSize
new2.48 KB

I've taken this patch a little further and updated it to create subdirectories on the AWS S3 server. Basically I extract the subdirectory path from the imagecache path or URL, and insert it into the appropriate path or URL.

It's working for me at this point. See the attached patch against 6.x-1.1

tnichols’s picture

Status: Reviewed & tested by the community » Patch (to be ported)
StatusFileSize
new2.94 KB

Updated the patch. The previous patch had a bug causing images to be created in a "." sub-bucket on S3 if the images were not in subdirectories.

hozt’s picture

Assigned: Unassigned » hozt
Status: Patch (to be ported) » Closed (fixed)

Fix has been integrated in current dev release and CVS. Re-open if needed.

j0e’s picture

I tried using the dev version and applying the patches in this thread independently, with the intention of restoring the file naming from preset_18 to sites/default/files/presetname/filename. It did chase down the default comment pics and default filefield images, and rename those, but didn't provide a sites/default/files naming convention and directories for the cloudfront pics.

It would be good if the file naming were consistent, because, similar to this thread: http://drupal.org/node/790810, I'm trying to deal with integration with the colorbox module. When it opens in the colorbox, it reverts to the local file. I thought having the cloudfront directory naming perfectly consistent with the local sites/default/files would be a stepping stone. Then if I could get the simplecdn module to work in tandem, using the simplecdn api to apply to colorbox to switch the base url path of the colorbox image to cloudfront and walla, it would be served from cloudfront inside the colorbox too...sounds like it would do as a workaround to the issue.

Anyway, if anyone has some idea on how to use this module to write files using the same file naming convention as the local drupal file system path just with the cloudfront url substituted, that would be quite helpful.

Thanks,
Joseph

maneesh_thakur’s picture

Hi All,

Using cloudfront module on drupal 6.1, i see that the images from my server are pushed on to the S3 bucket into folder of type "preset_#"
But I dont see the image being served from amazon cloud front, rather they are still being served from local servers. I have done all changes as suggested in http://drupal.org/node/552934
Any suggestions on what I may have missed out here.

Thanks.

j0e’s picture

is your imagecache preset set for http version of url of cloudfront distribution? it doesn't work with https; i remember that causing me problems when setting it up.