Pinterest Featured Image Support

I've added the Pinterest code to Floating Social (Mind you it is very confusing what has been added manually as there is no visual indicator of what has been added)

Pinterest has a hard time grabbing the image for the page, the Image URL needs to be provided inside the code.

It is currently not possible to include PHP to fetch the image URL inside the Floating Social code box.

<a href="http://pinterest.com/pin/create/button/?media=IMAGE-URL-HERE">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
  • Kimberly

    woodenfox,

    Hi and Thanks for your feedback on this.

    I think I might have something to help :

    https://premium.wpmudev.org/forums/topic/add-pinterest-button-to-floating-social

    pop over to here:

    http://pinterest.com/about/goodies/

    Fill out the form (see screenshot) and grab the code.

    Then go to your Floating Social settings page:

    Admin --> Settings --> Floating Social

    /wp-admin/options-general.php?page=wdsb

    And then add it as a new service (see Screenshot)

    There are a couple more handy notes in there as well :slight_smile:

    Hope this helps!

    Best,

    Kimberly


    If this thread is not resolved because the suggested action did not work or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

  • woodenfox

    This does not solve the problem.

    The Pinterest JS is not smart enough to fetch the image automatically for the page. This is why an image must be specified within the code like this:

    <a href="http://pinterest.com/pin/create/button/?media=IMAGE-URL-HERE">Pin It</a>
    <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

    Floating Social appears on all of the pages of my site. That is 1000+ pages. This is why I need to insert PHP into the floating social "Custom Service Code" box. This allows me to fetch the image for every page and put it into the field Pinterest requires.

    This is very easy to fix. Simply allow Wordpress PHP inside the "Custom Service Code" box. This is the code I would like to include in the "Custom Service Code" box:

    <a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php echo pinterest_image() ?>&description=<?php the_title(); ?> on <?php bloginfo('url'); ?>" class="pin-it-button" count-layout="horizontal">Pin It</a>
    <script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

    When I do this now, I get something that looks like this:
    http://pages.talenthouse.com/x/2012-03-13_1843.png

  • Vladislav

    Hello,

    Seeing the sheer number of requests, adding Pinterest button will definitely be one of the priorities for Floating Social update. While adding arbitrary PHP execution support is possible, I must say, I'm reluctant to actually do it as it's pretty much an accident waiting to happen, especially on network installs. Perhaps some sort of macro replacement would be a better choice for this kind of situation?

    In the meanwhile, I believe that Pinterest should be able to recognize a subset of OpenGraph tags - at least, og:image should be supported. Is perhaps this something you can use?

  • Vladislav

    Hello,

    The latest plugin release (v1.5, just released) includes a Pinterest service. The new service will automatically use your post featured image for sharing on Pinterest. If it can't find the featured image to share, the default behavior is to not show the sharing button. Also, both of these behaviors can be relatively easily modified through hooks. If you're comfortable with PHP, I'll include some quick examples here.

    For an example, this will force the Pin button to show, no matter what:

    function fshf_show_pinterest ($show, $atts) {
    	return true;
    }
    add_filter('wdsb-buttons-pinterest', 'fshf_show_pinterest', 10, 2);

    The "wdsb-buttons-pinterest" filter takes 2 arguments - should the button be shown ($show) and an array of button features ($atts). The filter should return a boolean true or false - true meaning the button will be shown.

    This example will force all Pin buttons to share a Hello Kitty image from Wikipedia:

    function fshf_show_image ($image, $size) {
    	return 'http://upload.wikimedia.org/wikipedia/en/thumb/0/05/Hello_kitty_character_portrait.png/200px-Hello_kitty_character_portrait.png';
    }
    add_filter('wdsb-media-image', 'fshf_show_image', 10, 2);

    The "wdsb-media-image" filter also takes 2 arguments - the image found by the plugin (if any), and the size that was being looked for. The filter handling funciton is expected to return a string, which is the full URL to the image you want to be shared.

    There are some other filters you may want to use to modify the plugin behavior as well - if you wish, you can find them in the file lib/functions.php in the plugin directory.

  • Vladislav

    Hello,

    The reason the Pinterest button is not showing is most likely because the plugin didn't found an image for your post. By default, the plugin will look for the featured image for your post, and use that as Pinterest image. If this lookup fails, the plugin will just skip showing the Pinterest button, by default. The solution for this situation could be as easy as adding a featured image to your post. However, there are also some more advanced techniques of dealing with this situation, if the easy solution doesn't fit your scenario.

  • aecnu

    Greetings,

    Just checking if this issue was eventually resolved in another thread? Or by yourself separately to us? Or by us over email with you? Or using our live support?

    If so, no need to reply, that's great news.

    If not, or you have any more questions related to this thread, please feel free to post them below including any new symptoms or errors and tick the 'Mark as Not Resolved (re-open)' box below the post area (or else we'll miss it!)

    Otherwise, happy days, glad you got it sorted :slight_smile:

    Thank you all for being WPMU Dev Members!

    Cheers, Joe

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.