Drupal Technical
[Drupal] How to add a Pinterest button to an image in a Drupal site?
One of our clients requested us to add a Pinterest button to a set of images in their website which was running on Drupal. If you want to know how to add a Pinterest button to an image in your Drupal site then read on to know how we did it.
Follow the steps below.
- Add the following widget code to a block or in the .tpl file of your Drupal site.
<a href="http://pinterest.com/pin/create/button/?url=<?php print url($node_url, array('absolute' => TRUE));?> &media=<?php print render(file_create_url($node->field_image['und'][0]['uri'])); ?>"class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
<script type="text/javascript" src="//assets.pinterest.com/js/pinit.js"></script>
- The $node_url is the variable that represents the url of the node in which the image is uploaded
Hope that helps
If you are looking for professional assistance in configuring third party widgets in your Drupal site, get in touch with us.