Tagged: media, mediapress
Hi Karamveer,
here is a sample endpoint implementation for ajax request
https://pastebin.com/KnLT0vQbYou may update for your need to extend as you require.
Please do check the comment in code and validate accordingly.Regards
BrajeshThank you Karamveer,
I am looking forward to your feedback.Regards
BrajeshHi Brajesh,
I tried your given solution but not succeed, steps are used as below.
*Activities performed*-
1. Upload JPEG image in Media, from admin side.
2. Created Galleries programmatically.
3. Get and Use Attachment ID created in step 1.
4. Get and Use Gallery ID created in step 2.
5. Execute $result = mpp_import_attachment( $attachment_id, $gallery_id, $override = array() );Regards,
Karamveer SinghPlease share a var_dump of the $result.
Regards
BrajeshHello Brajesh,
I added/uploaded jpeg image from admin side and pass the attachment_id then below is the var_dump output of the $result.
object(WP_Error)#2175 (3) {
[“errors”]=>
array(1) {
[“invalid_type”]=>
array(1) {
[0]=>
string(19) “Invalid media type.”
}
}
[“error_data”]=>
array(0) {
}
[“additional_data”:protected]=>
array(0) {
}
}
{“success”:false,”data”:”Invalid media type.”}Regards,
Karamveer SinghHi,
As the result says, you are importing a file type which is not allowed in the gallery.There are two possible reasons:-
1. The media type is different from gallery type
2. Or the media type allowed in gallery does not support the extension used by your uploaded media.Please look into that.
Regards
BrajeshHello Brajesh,
Thank you for look into it.
Yes, it’s understandable from error that Media(Image) I uploaded is marked as not supported.
But on other hand when I uploaded same Image in same gallery from admin side then it’s perfectly added then how it’s start supporting that time.
I tried with many different Images.
also I checked the settings, “jpeg,jpg,gif,png” is allowed extension for photo.
Please correct me if I have to check anything more.
Regards,
Karamveer SinghHi Karamveer,
Thank you for the reply and the details.
I will test again and get back to you in 24 hours.Regards
Brajesh
You must be logged in to reply to this topic.