<?php
    $counter = 1;
    $media = new WP_Query(array('post_type'=>'muziq-media', 'posts_per_page' => $_GET['perpage'], 'paged' => $_GET['page']));

    while ($media->have_posts()) : $media->the_post();
        $image = get_post_meta( $post->ID, '_muziq_jellythemes_media_photo', true );
        $video = get_post_meta( $post->ID, '_muziq_jellythemes_media_video', true );
        $large = wp_get_attachment_image_src($image, 'large');

        if ($counter==1 || $counter==3) {
            $img = wp_get_attachment_image_src($image, 'muziq_jellythemes_gallery_medium');
            $class='med';
        } elseif ($counter==2) {
            $img = wp_get_attachment_image_src($image, 'muziq_jellythemes_gallery_big');
            $class='big';
        } else {
            $img = wp_get_attachment_image_src($image, 'muziq_jellythemes_gallery_small');
            $class='small';
        }
        $counter = $counter==7 ? 1 : $counter+1;

        $return .=  '<div class="thumbnail ' . implode(' ', get_post_class($class)) . '">
                        <a href="' . (empty($video) ? $large[0] : $video) . '" class="swipebox">
                            <img src="' . $img[0] .'" alt="' . get_the_title() . '">
                            <div class="rollover">
                                <i class="' . (empty($video) ? 'plus' : 'video') . '"></i>
                            </div>
                        </a>
                    </div>';
    endwhile;
    echo $return;
?>
