<?php
/*
Template Name: Images
*/
get_header(); global $gp; 

gp_get_hub_id( get_the_ID() );

?>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>	
		
	<?php gp_page_header( get_the_ID() ); ?>
		
	<div id="content-wrapper"<?php if ( $GLOBALS['gp_layout'] != 'gp-fullwidth' ) { ?> class="gp-container"<?php } ?>>

		<div id="content">

			<article <?php post_class(); ?>>

				<?php if ( get_post_meta( $GLOBALS['gp_hub_id'], '_wp_page_template', true ) == 'hub-template.php' ) { ?>
					<header class="entry-header small-header">
						<h2 class="entry-title"><?php echo gp_prefix_hub_title( get_the_ID() ); ?></h2>
					</header>
				<?php } ?>		
		
				<?php the_content(); ?>
						
				<?php 
			
				// Get image IDs
				$gp_image_ids = array_filter( explode( ',', $gp['images_gallery'] ) );	

				if( $gp_image_ids ) { ?>

					<div class="images-wrapper">
			
						<?php foreach ( array_reverse( $gp_image_ids ) as $gp_image_id ) { 
					
							// Get attachment data
							$attachment = get_post( $gp_image_id ); ?>
					
							<div class="image-loop">
						
								<?php $image = aq_resize( wp_get_attachment_url( $gp_image_id ), $gp['images_image']['width'], $gp['images_image']['height'], $gp['images_hard_crop'], false, true ); ?>
								<?php if ( $gp['retina'] == 'gp-retina' ) {
									$retina = aq_resize(wp_get_attachment_url( $gp_image_id ),  $gp['images_image']['width'] * 2, $gp['images_image']['height'] * 2, $gp['images_hard_crop'], true, true );
								} else {
									$retina = '';
								} ?>
					
								<a href="<?php echo wp_get_attachment_url( $gp_image_id ); ?>" data-rel="prettyPhoto[group]" class="prettyPhoto" title="<?php echo esc_attr( $attachment->post_excerpt ); ?>">
									<img data-original="<?php echo esc_url( $image[0] ); ?>" data-rel="<?php echo esc_url( $retina ); ?>" width="<?php echo absint( $image[1] ); ?>" height="<?php echo absint( $image[2] ); ?>" alt="<?php if ( get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true) ) { echo get_post_meta( get_post_thumbnail_id(), '_wp_attachment_image_alt', true); } else { the_title_attribute( array( 'post' => $GLOBALS['gp_hub_id'] ) ); } ?>" class="wp-post-image" />
								</a>
					
							</div>
																				
						<?php } ?>

					 </div><!-- END IMAGE WRAPPER -->

				<?php } else { ?>
			
					<strong class="no-items-found"><?php _e( 'No items found.', 'gp_lang' ); ?></strong>
			
				<?php } ?>
			
			</article><!-- END ARTICLE -->	

		</div><!-- END CONTENT -->

		<?php get_sidebar(); ?>

	</div><!-- END CONTENT WRAPPER -->
		
<?php endwhile; endif; ?>		
			
<?php get_footer(); ?>