WordPress.org

Ready to get started?Download WordPress

Forums

Control facebook image references based o thumbnails etc. (3 posts)

  1. scottbothel
    Member
    Posted 3 years ago #

    Here is a bit of code to help those trying to automate the specifying of images to be shown when being linked to by Facebook.
    The logic is
    1. If there's a featured image, get the url of the thumbnail.
    2. If not, get the url of the thumbnail of the first image in the post (by attachment relationship, meaning it has to be uploaded while editing that post.
    3. If still nothing, get a specified image from the theme directory.
    This creates a function to place in your functions.php file.

    [Code moderated as per the Forum Rules. Please use the pastebin]

    Feel free to improve this and comment.

  2. TimeHealer
    Member
    Posted 3 years ago #

    Aren't there plugins for this...

  3. scottbothel
    Member
    Posted 3 years ago #

    Oops... here is the code http://pastebin.com/F5JQr2cn

    And yes, there are plugins for this, but I appreciate having snippets like this for template development enabling rapid deployment of sites not dependent upon certain plugins.

Topic Closed

This topic has been closed to new replies.

About this Topic