Thank you for the great module.

With Firefox 3 on Linux, my pictures are names image001.JPG (note the uppercase extension).

I am using imagefield-6.x-3.0.tar.gz and image_fupload-6.x-3.0-rc2.tar.gz.

When I browse to a directory to BULK upload images, there are no files listed. Editing of the field in the content type to allow JPG and jpg does not work with the following error, "Only web-standard images (jpg, gif, and png) are supported through the image widget. If needing to upload other types of images, change the widget to use a standard file upload."

If I change imagefield_widget.inc:
the line with
$web_extensions = array('jpg', 'jpeg', 'gif', 'png');
to
$web_extensions = array('jpg', 'jpeg', 'gif', 'png', 'JPG', 'JPEG', 'GIF', 'PNG');
the problem is solved.

This is probably not a "clean" solution, but a hack. It would probably be nice if JPg and jPG worked.

Thank you again for the great module.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch’s picture

ImageField and FileField should be smart enough to allow files regardless of their extension. While the field-editing form restricts you to only entering lower-case extensions, when the check is performed from a user uploading a file, it should be case insensitive.

Another good idea just to keep you server clean is to install the Transliterate module, which (I believe) will automatically convert all file names to lower case on the server-side.

Anonymous’s picture

Maybe it's better to hack the code another way:
At line 274 in imagefield_widget.inc, just after the line

$web_extensions = array('jpg', 'jpeg', 'gif', 'png');

Change the line

if (count(array_diff($extensions, $web_extensions))) {

in

if (count(array_udiff($extensions, $web_extensions, 'strcasecmp'))) {

array_udiff uses an external function to test array items equality, while array_diff uses it's own == method, that's case insensitive.
strcasecmp matches two strings case-insensitive. Done! ;-)
Anycase it should be a must in such a module. Bye!

Joel MMCC’s picture

@#2: You should make a proper .patch out of that, Attach it to a Reply, and set the Status of this thread to “needs review.” That will call the PatchBot to come test your patch!

Anonymous’s picture

Thanks for the information, I'm pretty new to Drupal and I still don't know how to manage all that here on the community.
I'll send it asap! Thanks!

quicksketch’s picture

Project: ImageField » Image FUpload
Version: 6.x-3.0 » 6.x-3.0-rc2

This problem looks specific to Image FUpload. I tried the following workflow with ImageField alone and it works as expected:

- Set up an image field that allows "png jpg jpeg gif" extensions.
- Visit node/add/x, upload an image named "example.PNG"
- The image uploads properly and keeps it's upper-case extension.

The extension case should be ignored when performing the validation. When done with ImageField alone the extension can be any case, since there is a "i" after the regular expression comparison to indicate case-insensitive. So rather than making a change to ImageField to work-around a bug in Image FUpload, that module should instead just be fixed to allow case-insensitive extension checking when doing a bulk upload.

Leonth’s picture

Status: Active » Needs review
FileSize
1.57 KB

Allowing case-insensitive extension checking would be difficult as it is done by flash / the swf, not Drupal, PHP, or javascript. So if it is indeed possible it must be done on swfupload project (outside drupal).

Here's how to allow upper-case file extensions. It still won't allow files like *.jPg or *.pNG though (only pure upper-cased ones like *.JPG), but I bet not many people have that kind of file names...

grandcat’s picture

I think, that's right. Thank you for the patch, I'll check this one.

my-family’s picture

Thank you, the patch works perfectly for me (ImageField 6.x-3.1; Image FUpload 6.x-3.0-rc2).

Anonymous’s picture

Another option if you don't fancy hacking php code etc till this is properly fixed is to use a bash script (if you're using Linux/Unix/OS X of course, or cygwin) to convert all files to lowercase before attempting to upload files.

grandcat’s picture

Status: Needs review » Fixed

Committed to HEAD. Thx.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rfay’s picture

haggins’s picture

Version: 6.x-3.0-rc2 » 6.x-3.x-dev
Status: Closed (fixed) » Active
FileSize
1.13 KB

I'm using Image FUpload 6.x-3.x-dev (2010-Jul-11) and it's still not possible to upload/select files with uppercase extension for image nodes.
Here's the patch:

haggins’s picture

Status: Active » Needs review