Skip to content

Instantly share code, notes, and snippets.

@samikeijonen
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save samikeijonen/59134220d4cb769269ab to your computer and use it in GitHub Desktop.

Select an option

Save samikeijonen/59134220d4cb769269ab to your computer and use it in GitHub Desktop.
Enable Simple Lightbox in feature image when on singular page.
/**
* Enable lightbox in feature image when on singular page.
*
* @see: https://wordpress.org/support/topic/help-activating-slb-in-my-theme?replies=14
*/
function toivo_post_thumbnail() {
if ( post_password_required() || is_attachment() || ! has_post_thumbnail() ) {
return;
}
if ( is_singular() && !is_page_template( 'pages/front-page.php' ) && !is_page_template( 'pages/child-pages.php' ) ) :
if ( has_post_thumbnail() ) :
$full_image_url = wp_get_attachment_image_src( get_post_thumbnail_id(), 'post-thumbnail' );
$content = '<a class="post-thumbnail" href="' . $full_image_url[0] . '">' . get_the_post_thumbnail( $post_id, 'post-thumbnail' ) . '</a>';
if ( function_exists('slb_activate') ) :
$content = slb_activate( $content );
echo $content;
endif;
endif;
else : ?>
<a class="post-thumbnail" href="<?php the_permalink(); ?>" aria-hidden="true">
<?php
the_post_thumbnail( 'post-thumbnail', array( 'alt' => get_the_title() ) );
?>
</a>
<?php endif; // End is_singular()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment