Plugin Directory

Changeset 2407162


Ignore:
Timestamp:
10/27/2020 01:39:37 AM (5 years ago)
Author:
thumblink
Message:

Use the post’s featured image if available.

Location:
thumblink
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • thumblink/trunk/thumblink.php

    r2405717 r2407162  
    22/**
    33 * @package Thumblink
    4  * @version 1.0.0
     4 * @version 1.1
    55 */
    66/*
     
    99Description: Thumblink automatically creates thumbnails for all of your blog posts to make your links look better. A link to your WordPress site on platforms like Facebook, Twitter, and LinkedIn is often the first interaction you have with a visitor. The link's thumbnail is 3x larger than its text preview - if it looks ugly or unmaintained, they won't click on it. Thumblink automatically generates these thumbnails by taking a screenshot of each page.
    1010Author: Team Thumblink
    11 Version: 1.0.0
     11Version: 1.1
    1212Author URI: https://thumblink.com/
    1313*/
     
    1616function hook_thumblink() {
    1717        $url = get_page_link();
     18        if (has_post_thumbnail()) {
     19                $post_image = wp_get_attachment_image_src(get_post_thumbnail_id(), "full");
     20                if (!empty($post_image[0])) {
     21                        $post_image = $post_image[0];
     22                        echo "<meta property=\"og:image\" content=\"{$post_image}\" />";
     23                        return;
     24                }
     25        }
    1826        echo "<meta property=\"og:image\" content=\"https://generate.thumblink.com/?url={$url}\" />";
    1927}
Note: See TracChangeset for help on using the changeset viewer.