<div class="bw-post bw-pubdoc">
	<div>
		<h2><?php the_title(); ?></h2>
		<?php if (!empty($summary = get_field('wpcf-summary', get_the_ID()))) : ?>
			<div class="bw-summary"><?php echo $summary; ?></div>
		<?php endif ?>
		<?php
		if (get_field('link_type', get_the_ID())) {
			$link_url = get_field('wpcf-link-url', get_the_ID());
		} else {
			$link = get_field('acf-link-url', get_the_ID());
			$link_url = wp_get_attachment_url(intval($link));
		}
		?>
		<?php if ($link_url) : ?>
			<a href="<?php echo $link_url ?>" target="_blank" rel="noopener noreferrer" class="bw-download-button">PDF</a>
		<?php endif ?>
	</div>
	<div>
		<?php
		if (!empty($thumbnail_id = get_field('acf-thumbnail', get_the_ID()))) {
			if (isset($link_url)) echo "<a href=\"$link_url\"  target=\"_blank\" rel=\"noopener noreferrer\">";
			echo wp_get_attachment_image($thumbnail_id, 'medium');
			if (isset($link_url)) echo "</a>";
		} 
		?>
	</div>
</div>
