<?php global $gp;

// Portfolio Categories
$terms = get_the_terms( get_the_ID(), 'gp_portfolios' );
$cat_array = explode( ',', $GLOBALS['gp_cats'] );
$gp_portfolio_cats = null;
if ( ! empty( $terms ) ) {
	foreach( $terms as $term ) {
		if ( ! empty( $cat_array[0] ) ) {
			foreach( $cat_array as $cat ) {
				if ( $term->term_id == $cat ) {
					$gp_portfolio_cats .= strtolower( $term->slug ) . ' ';
				}
			}	
		} else {
			$gp_portfolio_cats .= strtolower( $term->slug ) . ' ';
		}	
	}	
}

?>

<article <?php post_class( 'portfolio-item ' . $gp_portfolio_cats . $gp['portfolio_item_image_size'] ); ?> data-portfolio-cat="<?php echo esc_attr( $gp_portfolio_cats ); ?>">

	<?php if( has_post_thumbnail() ) { ?>

		<div class="post-thumbnail featured-content">
			<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
				
				<?php if ( $GLOBALS['gp_format'] != 'portfolio-masonry' ) {
				
					$image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 700, 500, true, false, true );
				
				} elseif ( $gp['portfolio_item_image_size'] == 'wide' ) {
				
					$image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 1000, 500, true, false, true );
					
				} elseif ( $gp['portfolio_item_image_size'] == 'tall' ) {
				
					$image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 500, 1000, true, false, true );
					
				} elseif ( $gp['portfolio_item_image_size'] == 'large' ) {
					
					$image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 1000, 1000, true, false, true );								
				
				} else {
				
					$image = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), 500, 500, true, false, true );						
				
				} ?>
				
				<?php if ( $gp['retina'] == 'gp-retina' ) {
					$retina = aq_resize( wp_get_attachment_url( get_post_thumbnail_id( get_the_ID() ) ), $image[1] * 2, $image[2] * 2, true, true, true );
				} else {
					$retina = '';
				} ?>
				
				<img src="<?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(); } ?>" class="wp-post-image" />
							
			</a>
		</div><!-- END FEATURED IMAGE -->

	<?php } ?>

	<?php if ( $GLOBALS['gp_format'] != 'portfolio-masonry' ) { ?>

		<div class="loop-header">

			<h2 class="entry-title loop-title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

		</div>
	
	<?php } ?>
			
</article><!-- END PORTFOLIO ITEM -->