Summary: We are processing IPTC, EXIF and XMP metta data for every image that is uploaded and added them into custom editable fields.
At this time we have figured out how to process all of the data, extract it from images, create custom fields, allow users to edit/save the data, update it into the images XML layer, in the WordPress and Mediapress layer ect… However, the following areas elude us:
1- Where is the initial upload process started in PHP?
2- what functions can we call on upload/save to update the mediapress cache?
I have carefully examined the JS API documentation for the media up-loader
Without using “mpp:uploader” JS events is there a way to hook into the mediapress upload actions in PHP?
IE: What Medapress PHP functions/hooks/line numbers are related to the upload function?
What we want: when a user uploads an image we want to take the IPTC data and use that for the title and description. We want this to happen “on first upload” and without using the JS API.
If anyone can point us in the right direction, a function name or hook that would be great!
Thank you for your consideration.
Thank you for the question.
We use the ajax action ‘wp_ajax_mpp_add_media’ to start upload. you can find this code in mediapress/core/ajax/mpp-ajax.php
It uses local storage helper for upload
Hope that helps.
so… looking into add_action( ‘wp_ajax_mpp_add_media’, ‘my_custom_function’ );
but since that action does not exist till private function setup() in MPP_Ajax_Helper
because its a private function of the class it therefore seems to me that I am prevented from extending any functionality there… or am I wrong about this?
mpp_media_added – I see the same problem there as well.
add_action( ‘mpp_media_added’, ‘my_custom_function’, 9, 9 );
will that really work? Its not available till after MPP_Gallery_Categories_Helper-> setup()
but in that case I see its a public function… so, will that work?
1. You can completely rewrite the upload by attaching to ‘wp_ajax_mpp_add_media’ on a high priority(say 9).
If you do that, you will need to emulate the whole upload process as you see in the add_media.
It does not matter if the method is private as you are not using that method. You are simply getting called before that and return the response, so that method never gets called(since it is ajax request).
You can add to the action from anywhere, please make sure the file/code gets run before the action fires(it fires at very low priority, so even if you load on plugins_loaded, it will be fine).
ah, yes. I see. thank you very much.
I have carefully re-read your posts here and examined each function mentioned a second time.
I am now able to edit/save the media IPTC, XMP and EXIF on upload.
I want to make sure I am handling this clearly.
consider the following situation:
In my own class MPP_IPTC_data_Helper
add_action( ‘mpp_media_added’, array( $this, ‘my_add_media_IPTC’ ) );
— and that works great, I am able to edit the meta values I seek based on your suggestions.
however, should I also do this as well?
add_action( ‘wp_ajax_mpp_add_media’, array( $this, ‘my_add_media_IPTC’ ) );
when would I need/want to use wp_ajax_mpp_add_media, if at all?
You must be logged in to reply to this topic.