I am using the file entity patch in #1260050: Provide administrative UI for adding/removing file types so I have multiple image file types.
When I upload an image into a field I upload, press next, then have to select a file type from a list of my available image file types.
In a lot of cases this will be an unnecessary step as the field will be specific to the file type.
So it would be good if the field settings had a list of checkboxes for allowed file types and if only one file type is selected then that second step is skipped, otherwise the second step is choosing from the list of allowed types for that field.
Comment | File | Size | Author |
---|---|---|---|
#32 | remove_filetype_check-1901566-32.patch | 873 bytes | cpena |
#26 | resolve_the_allowed-1901566-26.patch | 3.09 KB | jstoller |
#18 | interdiff-1901566-16-18.txt | 1.49 KB | mkhamash |
#18 | resolve_the_allowed-1901566-18.patch | 3.13 KB | mkhamash |
Comments
Comment #1
Dave ReidThe allowed file types option already exists, it just isn't resolved with the new file_entity multi-step form workflow.
Comment #2
jstollerI'm fighting my way through this same problem right now. I have two file types that can be used with PDFs: document and board_agenda. I have one media upload widget that is supposed to support board_agenda exclusively, but when I upload a PDF it still asks me if the file should be classified as a board_agenda or a document. There is no media field on my site where this choice should be made by a user.
I'm changing this issue to a Bug Report, since it is clearly deviating from expected behavior.
I've been exploring the idea of using hook_file_type_alter() as a workaround, but unfortunately that function doesn't seem to have any knowledge of what field it was called from. $file->source is just listed as "upload." Other workaround suggestions would be appreciated while waiting for a fix.
Comment #3
jstollerHere's the workaround I came up with. It seems to work, but any suggestions for improvement would be appreciated.
Comment #4
stevieegee CreditAttribution: stevieegee commentedNot good. Below is better
Comment #5
stevieegee CreditAttribution: stevieegee commentedThis is a better patch.
Comment #6
joewhitsitt#5 works for me. i have a unique file type that shares some mimetypes with document. even though i selected my unique file type and not document, the media workflow was having me select the file type after upload. this patch seems to workaround that and places it in the correct file type.
Comment #7
Jeroen_005 CreditAttribution: Jeroen_005 at Pàu commented#5 works for me also. Maybe we can add this to the file_entity module?
Comment #9
Jeroen_005 CreditAttribution: Jeroen_005 at Pàu commentedRetest :-)
Comment #11
Leksat CreditAttribution: Leksat at Amazee Labs commentedI'm working on this, but some tests fail on my local on clean 7.x-2.x branch. Need to check if this happens with drupal.org testbot too.
Comment #12
Leksat CreditAttribution: Leksat at Amazee Labs commentedComment #13
Leksat CreditAttribution: Leksat at Amazee Labs commentedTestbot does not work? Or I did something wrong?
Comment #14
jstollerLooks like a typo in your file name. It should end in ".patch", but yours ends in ".-patch".
Comment #15
Leksat CreditAttribution: Leksat at Amazee Labs commented@jstoller, I did not get it, but anyway, I had no time to work on this. To quickly solve the issue, I applied #5 patch, and it works good.
Comment #16
mkhamash CreditAttribution: mkhamash at Vardot commentedThe logic in patch #5 is correct, I have only handled not selecting any file types and added comments to code.
Comment #18
mkhamash CreditAttribution: mkhamash as a volunteer and at Vardot commentedThe field instance settings (Allowed types, Enabled plugins, etc ...) are not always available, since file_entity_add_upload() form is not used for fields only for example (file/add/upload). so I have took the liberty to initialize the $form['#options'] array to stop causing notices if not settings are available, this will solve the Test notices for this current patch but it should solve other problems down the road and limit the numbers of isset & empty we use in the future.
Comment #19
museumboy CreditAttribution: museumboy commentedIf I add a file field to my form and choose Media as the widget I see options for selecting the appropriate file-type to accept. However when uploading I'm still asked to choose the file-type as if the prior settings had no relevance.
I really do not want to give anonymous users access to the media module. I think the multiupload or standard file widget is best here. Using those widgets I see no option for selecting file-type. How can I force this field to conform to a specific filetype?
Comment #20
Leksat CreditAttribution: Leksat at Amazee Labs commentedManually tested #18 and reviewed its code. Works good, looks good!
Comment #21
gausarts CreditAttribution: gausarts commented+1 RTBC. Thank you.
Comment #22
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commented+1
Comment #23
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commentedTested - still works with 2.0-beta3
Comment #24
potassiumchloride CreditAttribution: potassiumchloride commentedTested and confirmed to work on 2.0-beta3.
Comment #25
joseph.olstadPossibly needs a reroll , or a re-upload of the patch in order to wake up the bot and run the simpletests.
Please reroll this patch if necessary, and re-upload it and set to "needs review" so as to trigger the simpletests.
Comment #26
jstoller#18 didn't apply, so I rerolled the patch, but no changes to the code.
Comment #27
jstollerSetting back to RTBC.
Comment #28
joseph.olstadsetting author
Comment #30
joseph.olstadfixed in 7.x-2.x dev
Comment #32
cpena CreditAttribution: cpena commentedI've found that the portion of this patch that checks the filetype causes the media browser window to disappear before I get the chance to set field values for a given media file upload. So I've removed this portion from file_entity_get_filetype_candidates().
Comment #33
joseph.olstadcpena, perhaps you've not configured the plupload library correctly.
https://www.drupal.org/node/2843391
if you want bulk uploading to work you'll need to use the plupload library
to see a working environment you can have a look at the media_dev distribution as a base line and see how it's configured and what libraries it's using.
Or you can refer to the quick install guide https://www.drupal.org/node/2843391
this is a drush make file but gives you an idea of which modules, libraries to use. there's also some ACL settings if you want to enable that for ckeditor.
Comment #34
cpena CreditAttribution: cpena commentedHey jospeh.olstad, thank you for the recommendation. I tried out the make file settings and still experienced the issue media browser disappearing before I could get the chance to select file settings. The bulk upload functionality was working fine prior to applying the module update and the code snippet I indicated was the cause of the issue I experienced.
Comment #35
joseph.olstad@cpena, your text format (html or rich text or other) is not configured correctly or your allowed file types are not configured for the correct types (file entity types , file entity file field for image/video/audio/document type and or media configuration and text format configuration check those). That is why this patch works for you because you're short circuiting the allowed file types.
I don't recommend patching like this, best to add the missing allowed file types specific to your desired configuration.
Comment #36
cpena CreditAttribution: cpena commented@josepg.olstad I'll keep the current version of the file entity module as is and modify my allowed file types configuration to ensure the media browser works. Thank you.