/** * Builds the markup for the attachment drawer in directories * * @since 1.4 */ function bp_docs_doc_attachment_drawer() { $atts = bp_docs_get_doc_attachments(get_the_ID()); $html = ''; if (!empty($atts)) { $html .= '<ul>'; $html .= '<h4>' . __('Attachments', 'bp-docs') . '</h4>'; foreach ($atts as $att) { $html .= bp_docs_attachment_item_markup($att->ID, 'simple'); } $html .= '</ul>'; } echo $html; }
<?php if (bp_docs_is_doc_edit() || bp_docs_is_doc_create()) { ?> <?php bp_docs_media_buttons('doc_content'); } ?> <ul id="doc-attachments-ul"> <?php foreach (bp_docs_get_doc_attachments() as $attachment) { ?> <?php echo bp_docs_attachment_item_markup($attachment->ID); } ?> </ul>
/** * AJAX handlers for attachments * * @since 1.4 */ function bp_docs_attachment_item_markup_cb() { $attachment_id = isset($_POST['attachment_id']) ? intval($_POST['attachment_id']) : 0; $markup = bp_docs_attachment_item_markup($attachment_id); wp_send_json_success($markup); }
case 'image/png': case 'image/gif': $li = bp_docs_attachment_item_markup($attachment->ID); preg_match('#<a href="([^"]*)".*</a>#', $li, $matches); $image_url = $matches[1]; $thumb_url = $image_url; $thumb_url = str_replace('.jpg', '-150x150.jpg', $thumb_url); $imgHtml = '<div class="bp_docs_attached_img"><a class="fancybox" rel="doc" href="' . $image_url . '">' . '<img src="' . $thumb_url . '" class="doc-image">' . '</a>'; $li = str_replace('<span class="doc-attachment-mime-icon doc-attachment-mime-jpg"></span>', $imgHtml, $li); $li = str_replace('<span class="doc-attachment-mime-icon doc-attachment-mime-gif"></span>', $imgHtml, $li); $li = str_replace('<span class="doc-attachment-mime-icon doc-attachment-mime-png"></span>', $imgHtml, $li); $li = str_replace('</li>', '</div></li>', $li); $images[] = $li; break; default: $file = bp_docs_attachment_item_markup($attachment->ID); $files[] = $file; } } foreach ($images as $image) { echo $image; } ?> </div> <div style="clear:both"></div> <hr> <ul id="doc-attachments-ul"> <?php foreach ($files as $file) { echo $file; }