Created
April 6, 2017 15:13
-
-
Save tshafer/e8f56ce747e2ddc5647de752a34b9d0e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ( ! function_exists('lead_image')) { | |
/** | |
* * Display the post image | |
*/ | |
function lead_image() | |
{ | |
$categories = get_the_terms(get_the_ID(), 'category'); | |
$dataCategory = []; | |
if ( ! empty($categories)) { | |
foreach ($categories as $category) { | |
$dataCategory[] .= $category->slug; | |
} | |
} | |
if ($image = get_field('thumbnail')) { | |
return '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_the_ID())) . '" class="log-event" data-category = "' . implode(',', $dataCategory) . '"><img src="' . $image['url'] . '" class="img-responsive"/></a>'; | |
} elseif (has_post_thumbnail()) { | |
return get_the_post_thumbnail(get_the_ID(), 'large-hero', ['class' => "log-event img-responsive"]); | |
} else { | |
//return '<a href="' . get_the_permalink() . '"><img src="' . get_template_directory() . '/assets/img/washingtonian-thumb-grey.jpg" class="img-responsive"/></a>'; | |
} | |
} | |
} | |
if ( ! function_exists('post_category_image')) { | |
/** | |
* * Display the post image | |
*/ | |
function post_category_image() | |
{ | |
$categories = get_the_terms(get_the_ID(), 'category'); | |
$dataCategory = []; | |
if ( ! empty($categories)) { | |
foreach ($categories as $category) { | |
$dataCategory[] .= $category->slug; | |
} | |
} | |
if ($image = get_field('thumbnail')) { | |
return '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_the_ID())) . '" class="log-event" data-category = "' . implode(',', $dataCategory) . '"><img src="' . $image['sizes']['thumb-category'] . '" alt="' . get_the_title(get_the_ID()) . '" class="img-responsive"/></a>'; | |
} elseif (has_post_thumbnail()) { | |
return get_the_post_thumbnail(get_the_ID(), 'thumb-category', ['class' => "log-event img-responsive"]); | |
} else { | |
return '<a href="' . get_the_permalink() . '" title="' . esc_attr(get_the_title(get_the_ID())) . '" class="log-event" data-category = "' . implode(',', $dataCategory) . '"><img src="' . get_template_directory() . '/assets/img/washingtonian-thumb-grey.jpg" alt="' . get_the_title(get_the_ID()) . '" class="img-responsive"/></a>'; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment