Skip to content

Commit

Permalink
Adds a check for attachment (media) singles
Browse files Browse the repository at this point in the history
  • Loading branch information
coreymcollins committed Oct 1, 2018
1 parent 3f89259 commit 41f8e78
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions inc/hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ function _s_add_og_tags() {
$card_type = 'website';
}

// Media page.
if ( is_attachment() ) {
$attachment_id = get_the_ID();
$attachment_image_url = ( wp_attachment_is_image( $attachment_id ) ) ? wp_get_attachment_image_url( $attachment_id, 'full' ) : $card_image;
$card_image = $attachment_image_url;
}

?>
<meta property="og:title" content="<?php echo esc_attr( $card_title ); ?>" />
<meta property="og:description" content="<?php echo esc_attr( $card_description ); ?>" />
Expand Down

0 comments on commit 41f8e78

Please sign in to comment.