<?php

/**
 *
 * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
 * that is bundled with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 */

if (!function_exists('newsweek_thumbnail_function')) {

	function newsweek_thumbnail_function($size) {

		global $post;
		
		$html = '';

		$section = (is_home() || newsweek_is_archive() || is_search()) ? 'archive' : 'single';
		$class = ( $section == 'archive' ) ? ' blog-section' : '';
		$image_link = ( $section == 'archive' ) ? '<a class="blog-article-image-link" href="' . esc_url(get_permalink()) . '"></a>' : '';

		if (
			(
				$section == 'archive' &&
				( 
					has_post_thumbnail() ||
					newsweek_setting('newsweek_has_post_placeholder', true) == true
				) 
			) ||
			(
				$section == 'single' &&
				has_post_thumbnail() &&
				newsweek_setting('newsweek_hide_featured_image_full_content', false) == false
			)
	
		) {
	
			$html  = '<div class="pin-container' . esc_attr($class) .'">';
			$html .= $image_link;
			$html .= get_the_post_thumbnail($post->ID, $size);
			$html .= '</div>';
		
		}
	
		echo $html;
	
	}
	
	add_action( 'newsweek_thumbnail', 'newsweek_thumbnail_function', 10, 1 );
	
}

?>