• Hello.
    I need some help, with automatically duplicate images that are added to post (with custom meta method) – to Photo Gallery (Thats will be somes plugins, or standart gallery, does not matter to me).
    For add images to the post i am using plugin – (Multi Image Metabox), and it’s works for me.
    The function to save this images –

    $list_images = list_my_images_slots();
        foreach($list_images as $k => $i){
    	    if ( isset( $_POST[$k] ) ) {
    			check_admin_referer('image-liee-save_'.$_POST['post_ID'], 'image-liee-nonce');
    			update_post_meta($post_ID, $i, esc_html($_POST[$k]));
    		}
    	}

    So the question is, what function I can automatically add these photos to the gallery of the same name as the category of this post ?
    How i can add images in gallery from php ?
    It’s posible ?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    It’s possible, but there is no defined function to do this, you would need to create your own. You don’t actually duplicate the images, you would just tell the gallery which images to use from the current set available. This is normally done by attachment ID, I’m unsure if the multi image metabox still creates attachments or not.

    Exactly how you tell a gallery to use certain images will depend on what gallery you are going to use. For example, the default gallery gets attachment IDs from it’s shortcode call: [gallery ids="10,11,12,13,14"]

    Normally, one way to get the ID list would be to query for all image attachments belonging to the post. From that one could build a shortcode string and pass it to do_shortcode(). Other possibilities exist depending on your specific implementation.

Viewing 1 replies (of 1 total)
  • The topic ‘Duplicate images from the post to the gallery ?’ is closed to new replies.