Created
May 11, 2016 03:47
-
-
Save mpaccione/536060bba5567c0cf7d99334fb1e191b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ajax_load_back() { | |
$post_id = $_POST[ 'post_id' ]; | |
$the_post = get_post( $post_id, OBJECT); | |
$title = get_the_title($post_id); | |
$post = $the_post->post_content; | |
$text_content = preg_replace('/<img[^>]+./','', $post); | |
// $attachments = get_posts( | |
// array( 'post_type' => 'attachment', | |
// 'numberposts' => -1, | |
// 'post_mime_type' => 'image', | |
// 'post_status' => null, | |
// 'post_parent' => $the_post->ID ) | |
// ); | |
$attachments = get_attached_media( 'image', $post_id ); | |
if ($attachments) { | |
$index = 0; | |
foreach ( $attachments as $attachment ) { | |
$imageList .= '<div class="modal" onclick="modalImgSwap('. $index .');"> | |
<div class="modalThumb"> | |
<li style="background-image: url('.wp_get_attachment_url( $attachment->ID , false ).'");> | |
</div> | |
<div class="modalInner" style="background-image: url('.wp_get_attachment_url( $attachment->ID , false ).'")> | |
<div class="modalClose" onclick="closeModal()"></div> | |
</div> | |
</div>'; | |
$index += 1; | |
} | |
} | |
echo "<div class='close'>X</div>"."<div id='content'>"."<div id='gallery'><div class='listContainer'><div class='fadeScreen'></div>".$imageList."</div></div>"."<h6 class='postTitle'>".$title."</h6><div class='postText'>".$text_content."</div>"; | |
die(1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment