- Christian W Zagarskas on September 9, 2019 at 11:36 am #25245
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.
- Brajesh Singh on September 9, 2019 at 11:45 am #25246
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.
- Christian W Zagarskas on September 9, 2019 at 11:50 am #25247
Thank you! I will look closer at those.
Is there any way to hook into the following?
we need some way to update the initial $media_data on/around “first upload”
- Brajesh Singh on September 9, 2019 at 11:54 am #25248
Hi Almost, all of them provide you some opportunity to hook(action or filter) except the mpp_get_title_desc_from_meta.
I am hoping that you can hook into ‘mpp_media_added’ and update the settings/content for media as you please.
- Christian W Zagarskas on September 9, 2019 at 12:01 pm #25249
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?
- Brajesh Singh on September 9, 2019 at 12:09 pm #25250
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).
- Christian W Zagarskas on September 9, 2019 at 12:50 pm #25251
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?
- Brajesh Singh on September 9, 2019 at 11:04 pm #25262
‘mpp_media_added’ is more than efficient.
The other action ‘wp_ajax_mpp_add_media’ is not advised. It was a way in case you want to handle the things completely differently.
I am glad it is working now.
marking ti resolved.
You must be logged in to reply to this topic.