function get_media() { global $user_ID, $wpdb; $page = 1; if (isset($_POST['page'])) { $page = intval($_POST['page']); } if ($user_ID) { $where = $wpdb->prepare("WHERE post_author='%d' AND post_type='attachment' AND post_mime_type LIKE '%s'", $user_ID, 'image%'); $cnt = $wpdb->get_var("SELECT COUNT(ID) FROM " . $wpdb->prefix . "posts {$where}"); $rclnavi = new RCL_navi(20, $cnt, false, $page); $limit_us = $rclnavi->limit(); $medias = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "posts {$where} ORDER BY ID DESC LIMIT {$limit_us}"); $custom_url = '<div id="custom-image-url" style="padding: 10px;"> <h3>' . __('The URL to the image', 'wp-recall') . ':</h3> <input type="text" id="custom-url" name="custom-url" value=""> <input type="button" onclick="add_custom_image_url();return false;" class="recall-button" value="' . __('Insert image', 'wp-recall') . '"> <script type="text/javascript"> function add_custom_image_url(){ var url = jQuery("#custom-url").val(); var image = "<img class=alignleft src="+url+">"; var ifr = jQuery("#contentarea_ifr").contents().find("#tinymce").html(); jQuery("#contentarea").insertAtCaret(image+" "); jQuery("#contentarea_ifr").contents().find("#tinymce").focus().html(ifr+image+" "); return false; } </script> </div>'; if ($medias) { $fls .= '<div id="user-media-list">'; $fls = '<span class="close-popup"></span> ' . $custom_url . ' <div id="user-medias" style="padding: 10px;"> <h3>' . __('Media library user', 'wp-recall') . ':</h3> <ul class="media-list">'; foreach ($medias as $m) { $fls .= '<li>' . rcl_get_insert_image($m->ID) . '</li>'; } $fls .= '</ul>' . '</div>'; $fls .= $rclnavi->navi(); $fls .= '</div>'; $log['result'] = 100; $log['content'] = $fls; } else { $log['result'] = 100; $log['content'] = $custom_url . '<div class="clear"><h3 align="center">' . __('Images in the media library is not found!', 'wp-recall') . '</h3> <p class="aligncenter">' . __('Upload to your image and you will be able to use them in future from your media library.', 'wp-recall') . '</p></div>'; } } echo json_encode($log); exit; }