-
-
Save mariemosley/2340649 to your computer and use it in GitHub Desktop.
pinterest buttons on every image in a Blogger/Blogspot post using jquery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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