Skip to content

Commit

Permalink
OpenGraph metatags and Pinterest will use post featured image when th…
Browse files Browse the repository at this point in the history
…e OpenGraph image is not specified.
  • Loading branch information
dziudek committed Dec 20, 2012
1 parent 5758807 commit 31f2314
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion MeetGavernWP/gavern/helpers/helpers.layout.fragments.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,17 @@ function gk_social_api($title, $postID) {
}
// Pinterest
if(get_option($tpl->name . '_pinterest_btn', 'Y') == 'Y') {
$image = get_post_meta($postID, 'gavern_opengraph_image', true);

if($image == '') {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $postID ), 'single-post-thumbnail' );
$image = $image[0];
}


// configure Pinterest buttons
$pinterest_btn_attributes = get_option($tpl->name . '_pinterest_btn_style', 'horizontal');
$pinterest_output = '<a href="http://pinterest.com/pin/create/button/?url='.get_current_page_url().'&amp;media='.get_post_meta($postID, 'gavern_opengraph_image', true).'&amp;description='.$title.'" class="pin-it-button" count-layout="'.$pinterest_btn_attributes.'"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="'.__('Pin it', GKTPLNAME).'" /></a>';
$pinterest_output = '<a href="http://pinterest.com/pin/create/button/?url='.get_current_page_url().'&amp;media='.$image.'&amp;description='.$title.'" class="pin-it-button" count-layout="'.$pinterest_btn_attributes.'"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="'.__('Pin it', GKTPLNAME).'" /></a>';
}

return '<section id="gk-social-api">' . $fb_like_output . $gplus_output . $twitter_output . $pinterest_output . '</section>';
Expand Down
6 changes: 6 additions & 0 deletions MeetGavernWP/gavern/helpers/helpers.layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,12 @@ function gk_opengraph_metatags() {
$title = get_post_meta($postID, 'gavern_opengraph_title', true);
$type = get_post_meta($postID, 'gavern_opengraph_type', true);
$image = wp_get_attachment_url(get_post_meta($postID, 'gavern_opengraph_image', true));

if($image == '') {
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $postID ), 'single-post-thumbnail' );
$image = $image[0];
}

$desc = get_post_meta($postID, 'gavern_opengraph_desc', true);
$other = get_post_meta($postID, 'gavern_opengraph_other', true);
//
Expand Down

0 comments on commit 31f2314

Please sign in to comment.