Opened 12 years ago
Last modified 6 years ago
#22938 assigned enhancement
Presentation of hierarchical taxonomy in Media modal should be checkboxes rather than comma-separated tag list
Reported by: | yeswework | Owned by: | wonderboymusic |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | 3.5 |
Component: | Media | Keywords: | needs-patch |
Focuses: | ui, javascript | Cc: |
Description
Since 3.5, using register_taxonomy_for_object_type on attachments, if the taxonomy used is hierarchical, whereas in the edit attachment UI you see the normal list of checkboxes, in the corresponding modal it is presented as a comma-separated list of slugs, as if it were a non-hierarchical taxonomy (tags rather than categories). I'm sure this is not a bug / mistake / oversight, but at best it's a little unintuitive (you need to have memorised the category slugs to add new ones) and worst a bit dangerous (risk of adding unwanted categories), and it would be great if in future it was presented here too as a list of checkboxes.
Attachments (3)
Change History (33)
#6
@
10 years ago
Now the new 4.0 media library edit attachment modal shows categories as a comma-separated list of slugs, too. Why? This is a backward step.
#7
@
10 years ago
- Milestone changed from Awaiting Review to 4.1
I'd like to come up with a solution for this in 4.1. Definitely seems pretty weird to relegate hierarchical taxonomies to non-hierarchical-type input boxes.
#8
@
10 years ago
- Focuses javascript added
- Owner set to wonderboymusic
- Status changed from new to assigned
I will fall on this sword
This ticket was mentioned in IRC in #wordpress-dev by DrewAPicture. View the logs.
10 years ago
This ticket was mentioned in Slack in #core by jessepollak. View the logs.
10 years ago
#12
@
10 years ago
I have a patch for this incoming — I'll get it up later this evening. It's not perfect, so I'm hoping to get some feedback advice, then clean it up.
#13
follow-ups:
↓ 16
↓ 17
@
10 years ago
- Keywords has-patch dev-feedback needs-testing added; needs-patch removed
I'm attaching a patch & screenshot of an MVP of the fix for this. Right now, it displays the categories for a media item as a list of checkboxes and saves them. I have a few questions and TODOs:
- I use
wp_terms_checklist()
which in turn relies onWalker_Category_Checklist
which is relatively inflexible. Primarily, it can only output inputs of the formname=post_category[]
ortax_input[$taxonomy]
. That's a different form than what's used to savedAttachmentCompat
's in Backbone, so I have tostr_replace
to get it in the correct form. I know this is horrible, but I'm not sure what the best way to proceed is — should I rewriteWalker_Category_Checklist
, so it can be more modular?
wp_terms_checklist()
outputs to the buffer, so I useob_start()
etc to get the content which is passed via AJAX. Is this acceptable or — again — should I refactor to make it possible to get it as a string rather than output?
- In the
media.view.AttachmentCompat
class, I add an if statement in thesave
method that handles the case where the input is a series of checkboxes (before this, they were always a single input oftype=text
ortype=hidden
). Is this acceptable or should I subclassmedia.view.AttachmentCompat
specifically for ones that are taxonomies of some sort.
- I've only been testing this in the Attachment Edit & Create pages and with the
category
taxonomy. Can anyone think of other objects and/or taxonomies I should be testing on?
- I have done zero styling of the check box. Right now, on my checklist is: restrict height of container and add
overflow: scroll
, indent child categories, align checkbox and text, add visual border to contain checkboxes. Any other thoughts?
Appreciate any and all feedback :)
This ticket was mentioned in Slack in #core by jessepollak. View the logs.
10 years ago
#16
in reply to:
↑ 13
@
10 years ago
Replying to jessepollak:
- I use
wp_terms_checklist()
which in turn relies onWalker_Category_Checklist
which is relatively inflexible. Primarily, it can only output inputs of the formname=post_category[]
ortax_input[$taxonomy]
.
This may relate to issue #28053 - The saving of media modal fields doesn't cater for multiple form fields of the same name named with empty square brackets such as post_category[]
. You would expect these to get submitted and handled as an array but only the last field gets submitted.
Would handling that issue perhaps help here?
#17
in reply to:
↑ 13
@
9 years ago
- Keywords needs-patch added; has-patch dev-feedback needs-testing removed
Thanks for the initial patch, jessepollak. Some thoughts:
- I use
wp_terms_checklist()
which in turn relies onWalker_Category_Checklist
which is relatively inflexible. Primarily, it can only output inputs of the formname=post_category[]
ortax_input[$taxonomy]
. That's a different form than what's used to savedAttachmentCompat
's in Backbone, so I have tostr_replace
to get it in the correct form. I know this is horrible, but I'm not sure what the best way to proceed is — should I rewriteWalker_Category_Checklist
, so it can be more modular?
Yeah, definitely feel free to refactor, but it might be awkward in this case, since it looks like you need the $name
to contain a reference to the attachment ID. You could make this work with the creative use of a filter, or perhaps by breaking the $name
logic into a separate method of Walker_Category_Checklist
and then subclassing it so as to override.
wp_terms_checklist()
outputs to the buffer, so I useob_start()
etc to get the content which is passed via AJAX. Is this acceptable or — again — should I refactor to make it possible to get it as a string rather than output?
Definitely yes. An 'echo'
param would be good.
- In the
media.view.AttachmentCompat
class, I add an if statement in thesave
method that handles the case where the input is a series of checkboxes (before this, they were always a single input oftype=text
ortype=hidden
). Is this acceptable or should I subclassmedia.view.AttachmentCompat
specifically for ones that are taxonomies of some sort.
What you've done in the patch seems OK to me. If this is the only change necessary, let's not overengineer.
- I've only been testing this in the Attachment Edit & Create pages and with the
category
taxonomy. Can anyone think of other objects and/or taxonomies I should be testing on?
I don't think you need to handle other objects with this ticket. For taxonomies, you should handle any taxonomy where 'hierarchical' => true
.
This ticket was mentioned in Slack in #core-images by joemcgill. View the logs.
8 years ago
This ticket was mentioned in Slack in #core by joemcgill. View the logs.
8 years ago
#21
@
8 years ago
I think it should look more similar to selecting or creating a category in a post.
Btw here is a screenshot from: https://wordpress.org/plugins/media-taxonomies/
(I have made a google doc comparing various media management plugins: https://docs.google.com/document/d/1Xgt8Cjv8rNcPwEwpECp3FgCOA5v1ehSkaA0uEFdQX6c/edit )
Btw
There are plans on more research and on looking into adding taxonomies into the media library. If you want to get involved check out the core-images posts on make.wordpress.org/core/
This ticket was mentioned in Slack in #core-images by joemcgill. View the logs.
8 years ago
This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.
8 years ago
#24
@
8 years ago
Besides the UI choices (select2, metabox like in edit screen, ...) one thing that might enhances the current text input for attachment category would be a UI notice that shows to the user that the terms were saved.
It's not evident to the user that category terms are saved until the text input "refresh" with terms listed by alphabetical order ASC.
Also, I was thinking about enhancing the current text input with an "autosearch" feature. Just like the one implemented in the content editor when defining an anchor link. Perhaps re-use the existing work for the editor and provide similar autosearch for existing terms and if it doesn't add them to the input and finally return a UI (UX?) element that tells the user the terms were saved.
What do you think?
This ticket was mentioned in Slack in #core-media by joemcgill. View the logs.
7 years ago
This ticket was mentioned in Slack in #core-media by desrosj. View the logs.
7 years ago
This ticket was mentioned in Slack in #core-media by paaljoachim. View the logs.
7 years ago
#29
@
7 years ago
Here is a link to WP Media Folder - Media Manager with Folders:
https://www.joomunited.com/wordpress-products/wp-media-folder
To show what a possible folder structure could look like.
shows a hierarchical taxonomy presented like a tag list in 3.5 media modal