[wp-hackers] Getting context inside the add_attachment hook

Ricardo Moraleida moraleida at gmail.com
Fri Oct 5 21:59:02 UTC 2012


I've managed to work around it in a dirty way, passing a fake post_id to
media-upload.php, which in turn gets passed to async_upload.php and can
then be retrieved from the add_attachment hook.

If anyone knows of a cleaner way to do this, please share.

thanks!


Ricardo Moraleida



2012/10/5 Ricardo Moraleida <moraleida at gmail.com>

> Hey,
>
> is there a way to find out from which page the media_uploader was called
> inside the add_attachment hook (i.e right after each upload completes) ?
>
> I've tried passing GET values to media-upload.php and using
> is_page('pagename'), but still no dice.
>
> The case use is that I'd like to invert the process of creating posts for
> a custom post type. Instead of creating a post and uploading an image,
> uploading images/files would create a post and attach themselves to it
> automatically. It's doable inside add_attachment, but i need to constrain
> this to happen only to a specific post type.
>
> thanks!
>
> Ricardo Moraleida
>
>


More information about the wp-hackers mailing list