WordPress.org

Ready to get started?Download WordPress

Forums

Facebook Like Button for Dummies
Add Use Featured Image? to options (2 posts)

  1. kwoodall
    Member
    Posted 3 years ago #

    You should have the plugin use the featured image, if one is specified, instead of grabbing the first image from the post.

    Kermit Woodall
    [ Signature moderated. ]

    http://wordpress.org/extend/plugins/facebook-like-button-for-dummies/

  2. kwoodall
    Member
    Posted 3 years ago #

    Fixed it myself. Here's the code.

    Kermit Woodall
    [ Signature moderated. ]

    ` private function getImage() {
    global $post;
    $thumb ='';
    if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
    return $thumb['0'];
    }
    else if (is_single() || is_page()) {
    $imgs = get_children('post_type=attachment&post_mime_type=image&post_parent='.$post->ID);
    if (is_array($imgs) && !empty($imgs)) {
    return wp_get_attachment_thumb_url(current($imgs)->ID);
    } else if ($img = $this->getFirstImage()) {
    return $img;
    }
    }
    return $this->openGraphImage;
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic