<?php
/**
 * Front page featured single item
 *
 * @package loop
 */

switch ( $post->post_type ) {
	case 'activity':
		$featured_cover = get_field( 'featured_image' );
		$featured_src = $featured_cover['size']['large'];

		// $terms = get_the_terms( $featured->ID, 'activity-type' );
		// $featured_type = $terms[0]->name;
		$names_string = '';

		$artists = get_field( 'artists' );

		if ( $artists ) {
			$names_string = get_artists_string( $artists );
		} else {
			$speakers = get_field( 'speakers' );
			if ( $speakers ) {
				$names_string = get_authors_string( $speakers );
			} else {
				$participants = get_field( 'participants' );
				if ( $participants ) {
					$names_string = get_authors_string( $participants );
				}
			}
		}

		break;

	case 'post':
	case 'page':
		// $featured_post_type = get_post_type_object( 'post' );
		// $featured_type = $featured_post_type->labels->name;
		$featured_src = get_the_post_thumbnail_url( get_the_ID(), 'large' );
		$names_string = get_field( 'subtitle' );

		break;
}

?>
<a href="<?php the_permalink(); ?>" class="home-featured-thumb">
	<div class="grid u_mh-min1">
		<div class="col--sm--one--half col--vam u_ph-1">
			<div class="home-featured-thumb__image-container">
				<img src="<?php echo esc_url( $featured_src ); ?>" alt="<?php the_title();?>">
			</div>
		</div>
		<div class="col--sm--one--half col--vam u_ph-1">
			<?php /* <h5 class="home-featured-thumb__type"><?php echo esc_html( $featured_type ); ?></h5> */ ?>
			<h3 class="home-featured-thumb__title"><?php the_title(); ?></h3>
			<h4 class="home-featured-thumb__names"><?php echo esc_html( $names_string ); ?></h4>
			<div class="home-featured-thumb__cta"><span class="home-featured-thumb__cta-text"><?php esc_html_e( 'Read more', 'far_loop' ); ?></span></div>
		</div>
	</div>
</a>
