WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#38195 new enhancement

Adding more mime_types filter to Media Library

Reported by: zodiac1978 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch dev-feedback has-screenshots ui-feedback
Focuses: Cc:

Description

In https://github.com/WordPress/WordPress/blob/e0a0be9579bf00c673f6fa9c68e87d4546271b37/wp-includes/post.php#L2191-L2206 WordPress is defining some default mime_types for filtering purpose in the media library.

At the moment this is everything starting with image, audio and video.

But there are more mime_types possible:
https://codex.wordpress.org/Function_Reference/get_allowed_mime_types#Default_allowed_mime_types

What about adding these mime_types in the way shown in #30788 ?

I suggest the following groups:

Documents:
-----------
application/pdf
application/rtf
application/msword
application/onenote
application/wordperfect
application/vnd (should handle MS, LO/OOo and iWorks)
text/plain
text/csv
text/calendar
text/tab-separated-values
text/richtext
Web-Documents
--------------
text/css
text/html
application/javascript
application/x-shockwave-flash
application/java
Archives:
---------
application/x-tar
application/zip
application/x-gzip
application/rar
application/x-7z-compressed
Misc:
------
application/x-msdownload (exe)

I'm just concerned about a possible performance problem.
See: #31071

Attachments (3)

38195.diff (4.5 KB) - added by zodiac1978 3 years ago.
Proof of concept
new-UI.png (79.4 KB) - added by zodiac1978 3 years ago.
The new dropdown would look like this
38195.2.diff (5.2 KB) - added by swissspidy 16 months ago.

Download all attachments as: .zip

Change History (14)

#1 follow-up: @lukecavanagh
3 years ago

@zodiac1978

Maybe to Documents:

Also add
application/epub+zip
application/x-mobipocket-ebook

#2 in reply to: ↑ 1 @zodiac1978
3 years ago

Replying to lukecavanagh:

Maybe to Documents:

Also add
application/epub+zip
application/x-mobipocket-ebook

This has to be added to the allowed mime types in wp_get_mime_types:
https://core.trac.wordpress.org/browser/tags/4.5.3/src/wp-includes/functions.php#L2336

I am talking about the filter dropdown in /wp-admin/upload.php.

@zodiac1978
3 years ago

Proof of concept

@zodiac1978
3 years ago

The new dropdown would look like this

#4 @zodiac1978
3 years ago

  • Keywords has-patch dev-feedback has-screenshots added

I think there is better way to achieve the same result. Maybe as an array and with implode? And some filters would be great to add more mime-types to the specific groups. But for now this is an proof of concept, how it can look if we want to implement this.

Version 0, edited 3 years ago by zodiac1978 (next)

#5 @swissspidy
2 years ago

  • Milestone changed from Awaiting Review to Future Release

#6 @zodiac1978
16 months ago

@swissspidy Any chance to get more feedback on this topic than "Future Release"? ;)
A "Wontfix" is totally okay, just want to know if this is something worth considering ...

@swissspidy
16 months ago

#7 @swissspidy
16 months ago

I just refreshed the patch in 38195.2.diff.

I like this enhancement, but it's probably best to bring this up in the weekly media chat in #core-media on Thursday to get a second opinion.

This ticket was mentioned in Slack in #core-media by mike. View the logs.


14 months ago

#9 follow-up: @karmatosed
14 months ago

  • Keywords ui-feedback added

I think right now I'd vote without thought to having 'Documents' added. I am less keen on all the other options, that's not saying some aren't really useful, I just would like to also work out the UI as we add more and more. Documents could be added now and that design problem doesn't need working out.

I would note that some terms used we totally should look at if we do add, for example terms like 'web documents' and 'interactives' could do with investigating if the right ones.

This brings up a design issue though as said, that many items in a drop down causes people to just skip over, not find what they are looking for. We should consider iterating the interface, over adding more than one extra here.

#10 in reply to: ↑ 9 @zodiac1978
5 months ago

Replying to karmatosed:

This brings up a design issue though as said, that many items in a drop down causes people to just skip over, not find what they are looking for.

It is worth mentioning that these new entries just show up if you upload files with these mime types.

I am happily discuss better wordings, but at the moment these are the only suggestions, why not starting with it? Or if you or someone else have specific problems with some of them, please write about it and suggest better ones. I was just trying to find words to describe groups of mime types because of the mentioned UI issue. I don't want to flood this drop down with too many new entries.

#11 @zodiac1978
3 months ago

I'm a little bit disappointed about the lack of specific feedback. Like I already mentioned these entries would just show up if there are files with these mime types uploaded.

I have tried to categorize all mime types for which uploading is allowed. Maybe it would have been better to wait for the discussion about these categories. Or I should have made a suggestion about just the useful categories, but I thought I should solve the bigger picture. Maybe I was wrong.

In the description of the ticket I made a first suggestion about this grouping.

These are the allowed mime types:
https://github.com/WordPress/WordPress/blob/master/wp-includes/functions.php#L2710-L2810

Images, Audio and Video is the status quo of the grouping:
https://github.com/WordPress/WordPress/blob/71cf332e6569f0ac2f263ce9b2168644942f5534/wp-includes/post.php#L2626-L2641

I am not sure if the categories used in the wp_get_mime_types inline docs are a good idea:
Image formats, Video formats, Text formats, Audio formats, Misc application formats, MS Office formats, OpenOffice formats, WordPerfect formats, iWork formats

Maybe the groups used in the wp_get_ext_types are better:
https://github.com/WordPress/WordPress/blob/master/wp-includes/functions.php#L2837-L2845

These would be:
image, audio, video, document, spreadsheet, interactive, text, archive, code

The first three are already used. We could add Documents. This seems to be widely accepted in the Slack. More questions / notices from Slack:

Interesting idea from @mikeschroder :

I think more around making it easy to sort by them in the media modal

Sorting would be great too. My use case is: I have uploaded a PDF and want to find it. I could search for ".pdf", but maybe using the dropdown is faster and more easy.

Issue mentioned from @karmatosed :

To me that list will only continue to grow.

I don't think, because this would handle all allowed mime types and if more mime types are added they could be added to one of the existing groups (like the the ebook mime types mentioned above) which could be added to Documents.

And another question from @karmatosed :

Do we know any examples that have solved this?

Yes, there are some plugins:

The most notable ones are these I think:
https://wordpress.org/plugins/media-library-assistant/ (adds Text and Applications which seems to be quite confusing)
and
https://wordpress.org/plugins/enhanced-media-library/ (adds Documents and PDFs)

Most of the other plugins are just adding specific mime types and are not setting these groups.

Like https://wordpress.org/plugins/mime-types-plus/ - but this is using the same grouping as wp_get_ext_types on their settings screen.

Some plugins are adding specific new groups for their use case (like Favicon Images, PDFs, Avatar Images, CSV for products, XML, GPX data, etc.)

All plugins using the filter can be found here:
https://wpdirectory.net/search/01D6AMX61FZ37RF534Z7BVS0B0

This search is even more helpful to get faster access to the added groups:
https://wpdirectory.net/search/01D6AQMY05PKKSFJP6HCW22127

Most plugins are adding PDFs. Or newly added extensions, but I found some plugins which have added more groups, like this ticket is suggesting.

https://wordpress.org/plugins/media-filter/
https://wordpress.org/plugins/wp-media-manager-lite/
https://wordpress.org/plugins/wp-admin-ui/
https://wordpress.org/plugins/media-library-shortcode/

All of theme using some variation sets of Archives/ZIPs/RARs/TARs, Documents/Docs, Office, OpenOffice, Excel, PDFs, etc. - But I think we should use generic naming and not something app/company specific, like MS Office or OpenOffice.

An one more issue from @karmatosed :

web-document to me just feels weird wording too.

This was my first suggestion. This could be "Text" or "Code" (belongs to the actual mime type). But I'm fine with adding just one or some few of them. For my use case Documents would be totally sufficient. Archives could be helpful too. I haven't uploaded any HTML or CSS file to media ... And Text, Spreadsheets and Interactives could be added to Documents too. Then we would have:
Images, Audio, Video, Documents, Archives

And one last from @karmatosed :

I’ll add my voice to ticket as I feel just get documents in then iterate is a win.

Maybe this is a language problem (I'm not a native English speaker), but I doesn't felt encouraged to to do so after the last comment. Re-thinking the UI looked like something which has to be done before this ticket can go further, so I stopped working it. But there was no discussion about re-thinking the UI ...

But maybe this research helps us to move further now. Any feedback is much appreciated.

Note: See TracTickets for help on using tickets.