By default, the "Add File" widget only allows you to upload .pdf or .txt files. So, this is something that lots of users will potentially want to change! However, changing it will cause panopoly_widgets Feature to become Overridden.

To make this super common change easier for users, I think we should:

  1. Put a field on the panopoly_widgets admin page for the list of file extensions
  2. Implement a hook_*_defaults_alter() (can't remember the exact hook name right now) that puts the value from that variable into the Field settings

That way users can easily change which extensions can be used, and the Feature won't be marked as Overridden!

(BTW, in Austin this is something @populist and @dsnopek discussed doing more of in Panopoly to make customizations easier and not necessarily require Features Override).

Original report

In file settings: admin/config/media/file-settings I have these extensions allowed for upload:

jpg jpeg gif png txt doc docx xls xlsx pdf ppt pptx pps ppsx odt ods odp mp3 mov mp4 m4a m4v mpeg avi ogg oga ogv wmv ico

I tried to upload a doc file in "Create a new custom entity" pane and got this message:

"Only files with the following extensions are allowed: pdf, txt."

Where do I set the allowed file types for this and why it's not replicating the general file settings?

Comments

maustyle’s picture

Issue summary: View changes
maustyle’s picture

Issue summary: View changes
mglaman’s picture

Status: Active » Postponed (maintainer needs more info)

Maustyle,

I haven't seen this "Create a new custom entity" pane before and it's not out-of-the-box Panopoly. What module provides that pane? Also, the issue is probably for that project. If you provide the name of the module (or if not sure, some of the modules you've added) I'll help debug and we can fix here or move to that project's queue.

maustyle’s picture

It shows up when you go to Panelizer first and add some content. then, when the admin layer pops up, click on 'Add file'.
then the 'Configure new Add file' layer appears, then see the screenshot. it only allows pdf and txt, but in my general settings

admin/config/media/file-settings

i have allowed more formats.

thanks for your help.

dsnopek’s picture

Title: Allowed file types don't match file settings » Allowe configuring file types for "File" widget without overriding the Feature
Issue summary: View changes
Status: Postponed (maintainer needs more info) » Active

Ok! This would then be the field settings for the field on the "Add File" fieldable panels pane. You can change what types are available at this path on your Panopoly site (as an admin): /admin/structure/fieldable-panels-panes/manage/basic-file/fields/field_basic_file_file

@maustyle: This should allow you to do what you want!

However, changing this will cause the panopoly_widgets Feature to become Overridden. I think this is a case where we should make it easier for users to change without the Feature becoming overridden (the trick is basically doing a hook_*_default_alter() in panopoly_widgets itself where we use the value of a variable). I've updated the issue summary to reflect what I'm thinking.

dsnopek’s picture

Issue summary: View changes
dsnopek’s picture

Title: Allowe configuring file types for "File" widget without overriding the Feature » Allow configuring file types for "File" widget without overriding the Feature
cboyden’s picture

I would also like to have the initial settings for the File widget include all of the non-image file types that are allowed by the Media Browser in WYSIWYG fields. Better not to update anything for existing sites; this would only be for new installations.

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new4.1 KB

Alright! Here is a patch that adds a setting on the Panopoly Widgets configuration page to set the list of allowed extensions without overriding the Feature. I also changed the default list of allowed extensions to match the allowed extensions for updating a Document file entity per @cboyden's suggestion - it really doesn't make sense to have two seperate defaults for the same use case: uploading a document.

dsnopek’s picture

Status: Needs review » Fixed

Committed!

  • dsnopek committed 9991ae6 on 7.x-1.x
    Updated Panopoly Widgets for Issue #2276089 by dsnopek, maustyle: Allow...
dsnopek’s picture

Status: Fixed » Active

Blergh! This breaks the automated tests:

https://travis-ci.org/panopoly/panopoly/jobs/47851286#L924

Basically, we just need to update the tests to check for the new list of default file types!

dsnopek’s picture

Status: Active » Needs review
StatusFileSize
new662 bytes

Here is a patch to panopoly_test to fix the tests. We'll see what Travis-CI says!

https://travis-ci.org/dsnopek/panopoly/builds/47866277

dsnopek’s picture

Status: Needs review » Fixed

Passed on Travis-CI, commiting!

  • dsnopek committed bef5d14 on 7.x-1.x
    Update Panopoly Test for Issue #2276089 by dsnopek, maustyle: Allow...
cboyden’s picture

Status: Fixed » Active

Part of the reason for this change is to allow sites or distros to change the allowed list without overriding the feature, so I think it might not be the right thing to hard-code the default list into the test. Does the feature need to check for allowed file types, and if so, is there a way to do it that's more flexible?

cboyden’s picture

Gah! I commented about the test thing on a stale browser window, so I didn't see @dsnopek's latest update. Somehow that also deleted the patch and reset the status?

dsnopek’s picture

Status: Active » Fixed
StatusFileSize
new662 bytes

Restored status and file attachment. :-)

Status: Fixed » Closed (fixed)

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