<?php
/**
 * @package pro
 */
?>


<div id="post-<?php the_ID(); ?>" <?php post_class(); ?> style="padding:<?php echo esc_attr($progression_studios_portfolio_gap) ?>;">
	
	<?php if(get_post_meta($post->ID, 'progression_studios_external_link', true)): ?>
		<a href="<?php echo esc_url( get_post_meta($post->ID, 'progression_studios_external_link', true) );?>" class="progression-studios-portfolio-index" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>>
	<?php else: ?>
		
		<?php if(get_post_meta($post->ID, 'progression_studios_lightbox_link', true)): ?>
			
					<?php if(get_post_meta($post->ID, 'progression_studios_video_post', true)): ?>
						<a href="<?php echo esc_url( get_post_meta($post->ID, 'progression_studios_video_post', true) );?>" data-rel="prettyPhoto[gallery]" class="progression-studios-portfolio-index" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>>
					<?php else: ?>
						<?php if(has_post_thumbnail()): ?>
						<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'large'); ?>
						<a href="<?php echo esc_attr($image[0]);?>" <?php $get_description = get_post(get_post_thumbnail_id())->post_excerpt; if(!empty($get_description)){ echo 'title="' . $get_description . '"'; } ?> data-rel="prettyPhoto[gallery]" class="progression-studios-portfolio-index" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>>
						<?php else: ?>
							<a href="<?php the_permalink(); ?>" class="progression-studios-portfolio-index" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>
						<?php endif; ?>
					<?php endif; ?>
			
		<?php else: ?>
			<a href="<?php the_permalink(); ?>" class="progression-studios-portfolio-index" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>>
		<?php endif; ?>
	<?php endif; ?>
	

		<?php if(has_post_thumbnail()): ?>
			<div class="progression-studios-portfolio-image">
				<?php if($portfolio_cropping_image == 'true' ): ?>
					<?php the_post_thumbnail('progression-portfolio-index'); ?>
				<?php else: ?>
					<?php the_post_thumbnail('progression-portfolio-uncropped'); ?>
				<?php endif; ?>
			</div>
			<?php else: ?>
				
				<?php if(get_post_meta($post->ID, 'progression_studios_gallery', true) ): ?>
					<div class="progression-studios-portfolio-image">
						<div class="flexslider progression-studios-gallery">
					      <ul class="slides">
								<?php $files = get_post_meta( get_the_ID(),'progression_studios_gallery', 1 ); ?>
								<?php foreach ( (array) $files as $attachment_id => $attachment_url ) : ?>
								<li>
									<?php echo wp_get_attachment_image( $attachment_id, 'progression-portfolio-index' ); ?>
								</li>
								<?php endforeach;  ?>
							</ul>
						</div><!-- close .flexslider -->
					
					</div><!-- close .progression-studios-feaured-image -->
				<?php else: ?>
				
					<?php if(get_post_meta($post->ID, 'progression_studios_video_post', true)): ?>
						<div class="progression-studios-portfolio-image progression-studios-portfolio-video"><?php echo apply_filters('the_content', get_post_meta($post->ID, 'progression_studios_video_post', true)); ?></div><!-- close .progression-studios-feaured-image -->
					<?php endif; ?>
					
				<?php endif; ?>
		<?php endif; ?>
		
		<div class="progression-portfolio-overlay">
			
			<h2 class="progression-portfolio-title" <?php if($portfolio_heading_size): ?>style="font-size:<?php echo esc_attr($portfolio_heading_size) ?>;"<?php endif ?>><?php the_title(); ?></h2>
			
			<?php 
				$terms = get_the_terms( $post->ID , 'portfolio-category' ); 
				if ( !empty( $terms ) ) :
					echo '<ul class="portfolio-tax-progression">';
				foreach ( $terms as $term ) {
					$term_link = get_term_link( $term, 'portfolio-category' );
					if( is_wp_error( $term_link ) )
						continue;
					echo '<li>' . $term->name . '</li>';
				} 
				echo '</ul>';
				endif;
			?>
			
		</div>


	<div class="clearfix-pro"></div>
	</a><!-- close .progression-studios-portfolio-index -->
	
	
	<div class="progression-portfolio-underneath-content" <?php if($portfolio_background_color): ?>style="background:<?php echo esc_attr($portfolio_background_color) ?>;"<?php endif ?>>
		
		<h2 class="progression-portfolio-title" <?php if($portfolio_heading_size): ?>style="font-size:<?php echo esc_attr($portfolio_heading_size) ?>;"<?php endif ?>><?php if(get_post_meta($post->ID, 'progression_studios_external_link', true)): ?><a href="<?php echo esc_url( get_post_meta($post->ID, 'progression_studios_external_link', true) );?>"><?php else: ?><a href="<?php the_permalink(); ?>"><?php endif; ?><?php the_title(); ?></a></h2>
		
		<?php 
			$terms = get_the_terms( $post->ID , 'portfolio-category' ); 
			if ( !empty( $terms ) ) :
				echo '<ul class="portfolio-tax-progression">';
			foreach ( $terms as $term ) {
				$term_link = get_term_link( $term, 'portfolio-category' );
				if( is_wp_error( $term_link ) )
					continue;
				echo '<li><a href="' . $term_link . '">' . $term->name . '</a></li>';
			} 
			echo '</ul>';
			endif;
		?>
		
		
	</div>
	
</div><!-- #post-## -->