<?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('urbanews_thumbnail_function')) {

	function urbanews_thumbnail_function($size) {

		global $post;
		
		$html = '';

		$section = (is_home() || urbanews_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() ||
					urbanews_setting('urbanews_has_post_placeholder', true) == true
				) 
			) ||
			(
				$section == 'single' &&
				has_post_thumbnail() &&
				urbanews_setting('urbanews_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( 'urbanews_thumbnail', 'urbanews_thumbnail_function', 10, 1 );
	
}

?>