Skip to content

Instantly share code, notes, and snippets.

@mariemosley
Forked from 65/pinterest.js
Last active September 28, 2022 15:17
Show Gist options
  • Save mariemosley/2340649 to your computer and use it in GitHub Desktop.
Save mariemosley/2340649 to your computer and use it in GitHub Desktop.
pinterest buttons on every image in a Blogger/Blogspot post using jquery
<script type="text/javascript">
$(document).ready(function() {
$('.entry-content img').each(function(){
$permalink = $(this).parents('.post-outer').find('.timestamp-link').attr('href') || $(location).attr('href');
$title = $(this).parents('.post-outer').find('.entry-title').text();
$(this).addClass('pinme').after('<a href="http://pinterest.com/pin/create/button/?url=' + $permalink + '&media=' + $(this).attr('src') + '&description=' + $title + '" class="pin-it-button" count-layout="horizontal"></a>');
});
});
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment