[wp-trac] [WordPress Trac] #14829: More hooks/actions required for Media Uploader
WordPress Trac
wp-trac at lists.automattic.com
Fri Jul 27 18:18:32 UTC 2012
#14829: More hooks/actions required for Media Uploader
-------------------------------------------+------------------------------
Reporter: Alhadis | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Upload | Version: 3.0.1
Severity: normal | Resolution:
Keywords: needs-patch reporter-feedback |
-------------------------------------------+------------------------------
Comment (by martythornley):
There are hooks to control what you can do with images uploaded through
the thickbox window. It just is really tough to find and not at all
intuitive. The real problem is that the functions in media.php are very
confusing and redundant and it takes following a thread of function to
function to function to track down what is doing what.
It is easy enough to add your own tabs to the thickbox but if you want to
add say an extra checkbox or setting to each image within the current list
of uploaded images, that would need some hooks. As mentioned in the ticket
description, I had to resort to javascript to insert some checkboxes.
For example, I will attach a zipped plugin that I wrote to allow bulk
insert of images. It uses the following
{{{
add_filter ( 'media_upload_image' ,
'bulk_image_alter_image_uploads');
add_filter ( 'media_upload_gallery' ,
'bulk_image_alter_image_uploads' );
add_filter ( 'media_upload_library' ,
'bulk_image_alter_image_uploads' );
}}}
Then the bulk_image_alter_image_uploads() function returns either a custom
function ( bulk_image_insert_to_editor() ) that mimics the built in one or
adds another filter so other plugins can hook in. So in another plugin for
image galleries, I used this new hook to interrupt the upload process and
send images to my own folder instead of the standard uploads folder, then
sent them back to a metabox instead of the editor.
The bulk_image_insert_to_editor() handles the uploads, then returns
another mimic function bulk_image_fast_insert_to_editor() instead of the
core insert to editor function.
So I guess it would be nice if all those steps had a hook in it, so that
any one could be replaced, whereas I had to replace all three?
It is related to http://core.trac.wordpress.org/ticket/21329, where I
tried to consolidate at least the initial hooks a little but I think that
whole set of functions in media.php could use some refining.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/14829#comment:8>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list