function get_gallery_list($temp_gal)
 {
     $attachlist = '';
     foreach ((array) $temp_gal as $attach) {
         $mime_type = get_post_mime_type($attach['ID']);
         $attachlist .= rcl_get_html_attachment($attach['ID'], $mime_type);
     }
     return $attachlist;
 }
function rcl_insert_attachment($attachment, $image, $id_post = false)
{
    $attach_id = wp_insert_attachment($attachment, $image['file'], $id_post);
    $attach_data = wp_generate_attachment_metadata($attach_id, $image['file']);
    wp_update_attachment_metadata($attach_id, $attach_data);
    if (!$id_post) {
        rcl_update_tempgallery($attach_id, $image['url']);
    }
    return rcl_get_html_attachment($attach_id, $attachment['post_mime_type']);
}