Is it possible to use a custom image for the PinIt button? I didn't find any valuable information about this, and I already use a custom folder with my images but the pinterest one (pinterest.png) doesn't get picked.
Thanks in advance

Files: 

Comments

The button is loaded dynamically directly from Pinterest. You'd need to have a non-widget share link specifically for Pinterest. I don't think Pinterest supports anything like that. Anyone know otherwise?

I've gotten pretty close...

By adding the following under general service I am getting everything except the node image.

  $links['pinterest_pin_it'] = array(
    'name' => 'Pinterest Piniter',
    'description' => t('Pinit on Pinterest'),
    'link' => 'http://pinterest.com/pin/create/bookmarklet/?media=<???>&url=<encoded-url>&title=<encoded-title>&is_video=false&description=<encoded-teaser>',
  );

If I could somehow call out the image URL this would work perfectly using the following:

http://pinterest.com/pin/create/bookmarklet/?
media=image URL (somehow)
&url=<encoded-url>
&title=<encoded-title>
&is_video=false
&description=<encoded-teaser>'

Anybody know how to pull that image url in?

@FranCarstens the 'preset' field and related function is what you need.

Thanks Crow. :D

@FranCarstens Any chance of providing the working code you used to for the custom Pinterest icon?

@SlakerD, Rather than making a patch, a new small module was better for my needs. below is an example of service_links_pinterest.module that I'm using to create a simple Pinterest service link. I could make a project page out of it, but I think it's best folded into service_links, rather than continue as a stand alone module. There are a few opportunities in the code to specify the image based on the current node: directly in the service_links_pinterest_preset() function or by implementing a hook anywhere else with hook_service_links_pinterest_NODE_TYPE().

<?php
/**
* @file
* provide a Pinterest link that is a non-widget
*/
/**
* Implements hook_service_links().
*/
function service_links_pinterest_service_links() {
 
$pinterest_link = 'http://pinterest.com/pin/create/bookmarklet/' .
   
'?media=<pinterest-media>' .
   
'&url=<encoded-url>' .
   
'&title=<encoded-title>' .
   
'&is_video=false' .
   
'&description=<encoded-teaser>';
 
$links = array();
 
$links['pinterest'] = array(
   
'name' => 'Pinterest',
   
'description' => t('Pin-it on Pinterest'),
   
'preset' => 'service_links_pinterest_preset',
   
'link' => $pinterest_link,
  );
  return
$links;
}
/**
* Callback for the Pinterest preset to setup the replacement token that
* identifies the image to pin
*
* @param type $service
* @param type $settings
* @param type $node
*/
function service_links_pinterest_preset(&$service, &$settings, $node = null) {
 
// Here, we can try and find an image in the node obj, or create and use a hook
  // to allow it to be defined elsewhere.
 
$results = module_invoke_all('service_links_pinterest_' . $node->type, $node);
 
// first one wins.
 
if (isset($results[0])) {
   
$result = $results[0];
  }
  else {
   
// TODO: search the $node fields for something that resembles an image?
   
$result = '';
  }
 
$settings['tag']['pinterest-media'] = '<pinterest-media>';
 
$settings['subst']['pinterest-media'] = $result;
}
/**
* implementation of hook_service_links_pinterest_NODE_TYPE
*
* return the pinterest image for an "article" node type.
*/
function service_links_pinterest_service_links_pinterest_article($node) {
  return
image_style_url('article_734x400', $node->field_article_photo['und'][0]['uri']);
}
?>

@Vali Hutchison

My workaround is unfortunately somewhat hardcoded, but it works. With a little work it should be possible to improve on it, but my php knowledge is lacking. I have the following:

I've added the following to the bottom of the general_services.module around line 142, in the "general_services_service_links" function:

<?php
  $links
['google_plus_share'] = array(
   
'name' => 'Google Plus share',
   
'description' => t('Share on Google+'),
   
'link' => 'https://plus.google.com/share?url=<encoded-url>',
  );
/*** Add Pinterest Pin-It Service ***/
   
$links['pinterest_pin_it'] = array(
   
'name' => 'Pinterest Piniter',
   
'description' => t('Pinit on Pinterest'),
   
'link' => 'http://pinterest.com/pin/create/bookmarklet/?media=<encoded-pinit>&url=<encoded-url>&title=<encoded-title>&is_video=false&description=<encoded-teaser>',
  );
/*** End Pinterest Pin-It Service ***/
 
echo drupal_get_path_alias('node/'.$node...
?>

Then I broke some rules and added the following to the service_links.module:

Around line 708, in the "_service_links_get_tags" function:

<?php
$nid
= $node->nid;
   
/** Add <pinit> "available value" -- this really just creates an available value for the first image, it can probably be used elsewhere also **/
   
$uri = $node->uc_product_image['und'][0]['uri']; /** get the public uri of the first image, in this case I'm using the uc_product_image field **/
   
$pinit = file_create_url($uri); /** convert the public url to the full url and make it available as a value **/
  
}
 
/** end of pinit addition **/
 
else {
else {
   
$title = drupal_get_title();
   
$url = _se...
?>

Then, around line 770, in the "$settings['tag'] = array(" I added the following:

<?php
   
'front-page' => '<front-page>',
   
/** Add the encoded pinit value **/
   
'encoded-pinit' => '<encoded-pinit>',
  );
?>

And again around line 806 in the "$settings['subst'] = array(" I added the following:

<?php
  
'front-page' => $front_page,
   
/** Add the encoded pinit value **/
   
'encoded-pinit' => $pinit,
  );
?>

Anybody who knows about coding will realise I have no idea what I'm doing, but, again, this worked for me.

You can change the icon using css background.

I am using:
version = "7.x-2.1+16-dev"
core = "7.x"
project = "service_links"
datestamp = "1362317389"

You can see it in use here: http://sqz.ee/Zk7

Category:Support request» Feature request
Issue summary:View changes
Status:Active» Needs review
StatusFileSize
new2.84 KB

Here's a patch made from a similar approach in #7