BuddyDev

Search

Pragmatically create mediapress Gallery!

Tagged: ,

  • Keymaster
    (BuddyDev Team)
    Posts: 24308
    Brajesh Singh on #49835

    Hi Karamveer,
    here is a sample endpoint implementation for ajax request
    https://pastebin.com/KnLT0vQb

    You may update for your need to extend as you require.
    Please do check the comment in code and validate accordingly.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 20
    karamveer on #49873

    Hi Brajesh,

    Thanks for sharing the solution, will use that one too asap will get back you with the output.

    Regards,
    Karamveer Singh

  • Keymaster
    (BuddyDev Team)
    Posts: 24308
    Brajesh Singh on #49885

    Thank you Karamveer,
    I am looking forward to your feedback.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 20
    karamveer on #49894

    Hi 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 Singh

  • Keymaster
    (BuddyDev Team)
    Posts: 24308
    Brajesh Singh on #49903

    Please share a var_dump of the $result.

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 20
    karamveer on #49921

    Hello 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 Singh

  • Keymaster
    (BuddyDev Team)
    Posts: 24308
    Brajesh Singh on #49928

    Hi,
    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
    Brajesh

  • Participant
    Level: Initiated
    Posts: 20
    karamveer on #49941

    Hello 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 Singh

  • Keymaster
    (BuddyDev Team)
    Posts: 24308
    Brajesh Singh on #49944

    Hi 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.

This topic is: not resolved