When using the inline module to load an image into the body of a blog post, I ran into a problem with one of three images. It appears the problem is that the image has a % in the filename. The src in the img tag was:
http://example.com/sites/default/files/imagecache/inline/blog/2009/02/04...
Which, if I go there directly, gives me a "400 Bad Request" error. However, if I properly URL encode the % sign:
http://example.com/sites/default/files/imagecache/inline/blog/2009/02/04...
It works fine. I will note that the link that wraps the image is correctly URL encoded ().
I believe the issue is that imagecache_create_url() should call drupal_urlencode() on the $path variable before passing it to file_create_url(). At least, that seems to fix it on my site.
function imagecache_create_url($presetname, $path) {
$path = _imagecache_strip_file_directory($path);
return file_create_url(file_directory_path() .'/imagecache/'. $presetname .'/'. drupal_urlencode($path));
}
Comments
Comment #1
korvus CreditAttribution: korvus commentedI accidentally overwrote my fixed version of ImageCache, so to prevent that in the future I just installed the Transliteration module. I do think that is an ugly hack, but since nobody seems to have noticed this in over a month and three beta releases, I am not hopeful about ImageCache correctly urlencoding it's image URLs in the future. That said, this should be fixed for those who are not using Transliteration.
Comment #2
drewish CreditAttribution: drewish commentedsee #357569: Add support for transliteration in the module