[wp-trac] [WordPress Trac] #14829: More hooks/actions required for Media Uploader

WordPress Trac wp-trac at lists.automattic.com
Fri Sep 10 08:22:54 UTC 2010


#14829: More hooks/actions required for Media Uploader
-------------------------+--------------------------------------------------
 Reporter:  Alhadis      |       Owner:                                                                             
     Type:  enhancement  |      Status:  new                                                                        
 Priority:  normal       |   Milestone:  Awaiting Review                                                            
Component:  UI           |     Version:  3.0.1                                                                      
 Severity:  normal       |    Keywords:  Thickbox, Media, Gallery, Uploader, Callback, Filters, Hooks, Edit, Gallery
-------------------------+--------------------------------------------------
 Okay, so the Media Uploader's API needs work.

 This is not just a suggestion; it's a revelation that occurred to me after
 nine solid hours of picking around uncompromising source code and relying
 on JavaScript and guesswork to add custom functionality.

 Many times I've found myself developing WordPress features that all
 attempted to manipulate or customise the Media Uploader thickbox in some
 way... many of which became completely unworkable due to the lack of hooks
 or filters provided by the source code. Furthermore, the way the uploader
 sends images back to the TinyMCE editor has made it incredibly difficult
 to "intercept" those commands and have them handled differently.

 Say I have a metabox added to the Edit Post screen that displays
 thumbnails to a computer illiterate client... ones that can be dragged
 around and rearranged to control the order of a slideshow that's shown
 above a page when loaded. Now, we've already shown the client how to
 insert images into a post using WordPress' Thickbox, and they've grown
 comfortable with traversing the tabs. So it only makes sense that we'd use
 the same interface for picking or uploading an image.

 What if we want to send those images somewhere else, like into a metabox?
 There's no apparent hook or callback provided by either PHP or JavaScript
 that allows plugin developers to implement this level of functionality.
 It's as though the Media Uploader was never intended to be touched or
 customised in any fashion. And so, my current solution relies solely on
 using jQuery for adding buttons and callbacks over the top of the existing
 interface. I'm up to the part that involves "stealing" the attachment's ID
 and trying to send it back to the Edit Post page in the background. Lot of
 work? Yes. Secure? No. At any given point in future, there's no guarantee
 that the core structure of the Media Items list will change, thereby
 breaking the plugin that relied on class-names and DOM traversal to apply
 buttons.

 In short, these are ridiculous lengths that I've had to go to to try and
 implement an enhancement to the Media Uploader. I don't want to go through
 the trouble of scripting an entirely new uploader specifically for plugins
 and theme features... I think we'd all agree it's in WordPress's nature to
 allow a degree of control over how the Uploader Thickbox works as well.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14829>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list