Split up images and text

Pulls out all your images in your post and puts it in a separate div.

Code Snippet:

<div class="content-text">
  <h2><?php the_title(); ?></h2>
  <?php
  ob_start();
  the_content('Read the full post',true);
  $postOutput = preg_replace('/<img&#91;^>]+./','', ob_get_contents());
  ob_end_clean();
  echo $postOutput;
  ?>
</div>
<div class="content-img">
  <?php
  preg_match_all("/(<img &#91;^>]*>)/",get_the_content(),$matches,PREG_PATTERN_ORDER);
  for( $i=0; isset($matches[1]) && $i < count($matches&#91;1&#93;); $i++ ) {
    echo $beforeEachImage . $matches&#91;1&#93;&#91;$i&#93; . $afterEachImage;}?>
</div>

Posted in Images, Posts