CCK 5.x-1.7
ImageField 5.x-2.1
775 for tmp and files
Public download
ImageField config N/A
Expected: image files show up in Open window after selecting Choose...
Unexpected: no sign of the files anywhere
Steps: Create a new content type with an Image field, leave settings at default
Attempted to upload an image but the image I want is not listed in the Open window when I go to my chosen folder. Even "Files of type" set at the wildcard selection does no good. Probably not an OS problem since I can select files in other applications.
Occurs only in Opera 9.5. IE7 and Firefox works fine.
Comments
Comment #1
dobeerman commentedhave you solved the issue?
Comment #2
drew reece commentedI have this issue too.
It seems that Opera on the PC enforces the file types for the image fields incorrectly. If the image field has "Permitted upload file extensions" set then Opera refuses to show any files at all.
Setting the file extensions to nothing allows files to be selected. This fixes the issue but runs the risk of users submitting any kind of file into the image field !
Frankly I think this is an Opera bug, but it way well be Windows at fault (XP in my case).
I'd like the project maintainer to tell us if disabling the types is as risky as I think it is? My concern is for files that will also be run through imagecache for scaling afterwards.
I'm using Opera 9.52 on XP.
Comment #3
drew reece commentedHas anyone got a test site set up to demo this problem?
Comment #4
drew reece commentedCreating a copy of the page (just copy the source to a new html page) and changing the values for the file input type from
accept="jpg|jpeg|png"toaccept="jpg,jpeg,png"makes Opera work correctly, but it breaks Safari & probably other browsers.I have had a look around to see how the
accept="…"should be formatted, but it is unclear to me. It seems that HTML (4 at least) expects comma separated, but they should be formatted as mime types eg image/jpg, image/jpeg… I cannot tell what XHTML expects, since it seems to inherit the specs from HTML & other RFC's.Is it the case that using pipes "|" means that the browser should interpret the values as extensions instead of mime types?
I'm still unclear if this is an Opera bug or incorrect markup.
Comment #5
curagea commentedYeah, it was Opera-only (on XP). I guess for now I'll stick to Firefox for devel.
Comment #6
drew reece commentedMy main site admin loves Opera, so it would be nice if it worked :)
Comment #7
off commentedSubscribing
Comment #8
premanup commentedthe same problem...
I think the line 714 imagefield.module should looks like this:
'#attributes' => array('class' => 'imagefield imagefield-'. $fieldname),
w/o accept parameter.
Comment #9
drew reece commentedPremAnup that looks correct,
Sorry I can't test right now but I'll try in the next couple of days.
I wonder if changing the following.
on line 714,
'accept' => str_replace(' ', '|', trim($field['widget']['file_extensions']))… to …
'accept' => str_replace(' ', ',', trim($field['widget']['file_extensions']))Looking at the html 4 specs, it seems commas should be used for the separator in the 'accept' mime type list.
http://www.w3.org/TR/REC-html40/interact/forms.html#adef-accept
Is that the case for XHTML 1.0 Strict ?
I guess if it works it must be right :)
Comment #10
drew reece commentedOK here is the problem as I see it.
Removing the 'accepts=' property will work, but then you could also just remove the permitted extensions in the image field settings, you get the same effect without hacking the module.
The accepts parameter should be separated by commas, so my comment #9 will work, accept for one problem. There is a javascript validation happening, that is preventing images being selected because the validation is looking for a vertical bar character that isn't there anymore.
The file in question is imagefield.js. I'm trying to understand the javascript regex but not getting too far with it.
FWIW This issue has "apparently" been fixed but it still seems to be the a problem with 5-x.2.1
http://drupal.org/node/280801
My clean version of imagefield 5.x-2.1 uses version imagefield.js,v 1.1.2.1 which has been fixed 4 months ago but still not released.
ARGH!!!
So the solution is to browse the CVS repository & use the versions that have the commit by dopry 'switch accept to use a , instead of |'
I think it is just the .module and the .js files you need from here…
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagefield/...
Can someone release this so we don't waste time fixing things that have been fixed already?
Comment #11
drewish commenteddrew reece, there have been problems with getting the -dev release packaged but i for one am not going to create a 2.2 release until i get some feedback on the current 5.x-2.x-dev release. the last thing i need is even more support issues that i don't have time for. we finally got http://drupal.org/node/157163 sorted out today so download it and if it's working let me know. but as it is this has already been fixed.
Comment #12
drew reece commentedDrewish,
I got it & installed on a stage site (minutes after the packaging script ran). It works in Opera on the PC - users can add images now.
One problem is that Opera throws up a dialog "JavaScript - Unspecified error" when the upload button is clicked. If I leave the script to continue it runs, and the image gets uploaded. This error also occurs on the file attach button (on file attachments etc) on nodes with no imagefields so I think it is from another script.
I reverted the module and the same "Unspecified error" also occurs with imagefield 5.x-2.1. It happens on the mac too, but so far only in Opera (latest version 9.62), not Firefox or Safari.
I'm unable to find the reason for the error, but at least now my admin can use Opera to submit images.
Setting breakpoints in Opera's error console seems to point to line line 38 of upload.js, but if I pin it down with some certainty I'll post to the appropriate issue queue.
One weird thing I noticed is that when an incorrect file type is added, the list of recommended types has a space only after the first type. The replace function on line 14 of imagefield.js is actually only replacing the first ',' in the string of allowed types. This needs to be altered…
Line 14 of imagefield.js is currently…
This needs to be more greedy :) …
WARNING I hacked this together and don't know ANY JavaScript (or jQuery I guess). Please check it. I simply added the 'accept' variable to the start of the error message string to be able to debug the string before it gets re-replaced on line 18.
This means that I can upload files that are not just first in the list of allowed types on my imagefield admin pages.
I hope this helps Drewish, thanks for sorting the CVS & packaging stuff, I have a hard time of making sense of the 'VC view CVS browser'.
I can add make a patch if you really want one.
Comment #13
drewish commentedYeah I think I had to fix that in HEAD as well... I need to compare the JS on those and sync it up.
Comment #14
drew reece commentedGreat, I'm even more confused, HEAD has no imagefield.js file ? I must be looking at the wrong thing
http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/imagefield/...
Anyway, I'd like to contribute but CVS makes little sense, but it's good that the dev snapshot is now tar'd & on the module page.
Comment #15
drewish commentedsorry should have mentioned it's moved into the filefield module: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/filefield/f...
Comment #16
drewish commentedactually, realized that i'd had to hack around filefield's crappy js in the audio module...: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/audio/audio...
i should probably get this right one place and then commit it everywhere.
Comment #17
drew reece commentedThat makes more sense now. I can see it makes sense to combine the similar parts since they are merging in Drupal 6. I'll test the next dev release when it changes. For now I'll trial my fixed version.
Thanks
Comment #18
drewish commenteddrew, could you test out the following patch? i'd like to standardize on this if possible.
Comment #19
drewish commentedactually that last one has a bug in it.
Comment #20
drew reece commentedI applied the patch via
patch < path/to/file.patchand gotpatching file imagefield.js
patch unexpectedly ends in middle of line
Hunk #1 succeeded at 4 with fuzz 1.
The JS validation worked, but it doesn't check if the files added after the first one are the correct type. It waits until the file is uploaded, then highlights all the image fields with the error above them all. The offending field is also removed at that point, so it's a little unclear how to fix it (hitting submit on the node does work).
I'm hoping my patching was OK.
Comment #21
svihel commentedSubscribing
Comment #22
jscheel commentedStill getting this error as well. The JS validator tells me a jpg file is not allowed, when jpg is in the accepted values list.
Edit: nevermind, I'm retarded.
Comment #23
yktdan commentedSubscribing. The current -dev does not work on Firefox. Going into Firebug and removing the accept clause lets it work. I did not try fancier fixes to the accept. I need gif to work at the moment, but other places I have jpg's. It also fails on IE7 and Chrome but I can't patch it with Firebug.
Comment #24
syndicut commentedSubscribing
Comment #25
quicksketchThanks drewish, I reviewed your changes and found only a few problems.
- Imagefield should still target it's own fields specifically: $("input.imagefield[@type='file']"), rather than all file elements.
- Imagefield errors have the class "imagefield-js-error", not "filefield-js-error".
I made these two changes then committed.