<?php
/**
 * Template part for displaying gallery posts masonry layout
 *
 * @link https://codex.wordpress.org/Template_Hierarchy
 *
 * @package WordPress
 * @subpackage Tattoopress
 * @version 3.3.4
 */
extract( wp_parse_args( $template_args, array(
	'layout' => '',
	'overlay_color' => 'auto',
	'overlay_custom_color' => '',
	'overlay_text_color' => '',
	'overlay_text_custom_color' => '',
	'overlay_opacity' => 88,
) ) );

$text_style = '';

if ( $overlay_text_color && 'overlay' === $layout ) {
	$text_color = tattoopress_convert_color_class_to_hex_value( $overlay_text_color, $overlay_text_custom_color );
	if ( $text_color ) {
		$text_style .= 'color:' . tattoopress_sanitize_color( $text_color ) . ';';
	}
}

$thumbnail_size = apply_filters( 'tattoopress_album_masonry_thumbnail_size', '' );

$dominant_color = tattoopress_get_image_dominant_color( get_post_thumbnail_id() );
$actual_overlay_color = '';

if ( 'auto' === $overlay_color ) {

	$actual_overlay_color = $dominant_color;

} else {
	$actual_overlay_color = tattoopress_convert_color_class_to_hex_value( $overlay_color, $overlay_custom_color );
}

$overlay_tone_class = 'overlay-tone-' . tattoopress_get_color_tone( $actual_overlay_color );
?>
<figure <?php tattoopress_post_attr( array( $overlay_tone_class ) ); ?>>
	<div class="entry-box">
		<div class="entry-container">
			<a class="entry-link" href="<?php the_permalink(); ?>">
				<div class="entry-image">
					<?php the_post_thumbnail( $thumbnail_size ); ?>
				</div>
			</a>
			<div class="entry-inner">
				<?php

					if ( $dominant_color && 'auto' === $overlay_color ) {
						$overlay_custom_color = $dominant_color;
					}

					/**
					 * Overlay
					 */
					echo tattoopress_background_overlay( array(
						'overlay_color' => $overlay_color,
						'overlay_custom_color' => $overlay_custom_color,
						'overlay_opacity' => $overlay_opacity, )
					);
				?>
				<div style="<?php echo tattoopress_esc_style_attr( $text_style ); ?>" class="entry-summary">
					<h3 class="entry-title"><a href="<?php the_permalink(); ?>" style="<?php echo tattoopress_esc_style_attr( $text_style ); ?>"><?php the_title(); ?></a></h3>
					<div class="entry-meta">
						<?php
							/**
							 * Gallery meta
							 */
							tattoopress_gallery_meta();
						?>
					</div><!-- .entry-meta -->
				</div><!--  .entry-summary  -->
			</div><!--  .entry-summary-container  -->
		</div>
	</div><!-- .entry-container -->
</figure><!-- #post-## -->