WordPress.org

Ready to get started?Download WordPress

Forums

Sharebar
A shortcode for post image thumbnail (2 posts)

  1. echezuria
    Member
    Posted 2 years ago #

    It will be great if you could add a shortcode like [thumbnail] for the Sharebar plugin to manage the post image thumbnail call: wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'thumbnail' )

    So, by just writing [thumbnail] we get the thumbnail url. Very usefull to embed buttons like "Pin it" from Pinterest that requieres an image url to be pinned.

    Thanks for your time!

    http://wordpress.org/extend/plugins/sharebar/

  2. echezuria
    Member
    Posted 2 years ago #

    It could work by just adding this update to your plugin source code (on sharebar_filter function):

    function sharebar_filter($input){
    global $post;
    $code = array('[title]','[url]','[author]','[twitter]','[thumbnail]');

    $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large' );
    $urlThumb = $thumb['0'];

    $values = array($post->post_title,get_permalink(),get_the_author(),get_option('sharebar_twitter_username'),$urlThumb);
    return str_replace($code,$values,$input);
    }

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags