Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Unminified code for a Pinterest gallery designed for use as an HTML/JavaScript gadget on Blogger. Minified version at: https://gist.github.com/mariemosley/f3bb583947d8cd04d3ad
<!-- BEGIN CODE IT PRETTY PINTEREST GALLERY -->
<style>
#pinterest-gallery {
overflow: auto;
width: 210px;
list-style: none;
}
#pinterest-gallery li {
float: left;
width: 100px;
height: 100px;
background-size: cover;
margin: .1em;
padding: 0;
border: none;
}
#pinterest-gallery img { border: none; }
.pinterest-link {
display: block;
overflow: hidden;
text-indent: 100%;
height: 100%;
white-space: nowrap;
}
/* Internet Explorer correction */
#pinterest-gallery li a {
color: transparent;
line-height: 1px;
font-size: 0px;
}
</style>
<div id="pinterest-gallery"></div>
<!-- If you already have jQuery installed in your template, remove the next line -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<!-- -->
<script type="text/javascript">
$( document ).ready(function() {
//GALLERY SETTINGS
var thumbnailCount = 6;
var username = 'codeitpretty';
var profile = true;
var board = false;
var boardname = '';
var newWindow = false;
//END GALLERY SETTINGS. DO NOT EDIT BELOW THIS LINE
var url;
var urlPrefix = 'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=https://www.pinterest.com/';
if ((board === true && profile === true) || ((board === false && profile === false))) {
$('#pinterest-gallery').append('<p>Error: please choose a profile gallery or board gallery.</p>');
}
else {
if (profile === true) {
url = urlPrefix + username +'/feed.rss&num='+thumbnailCount;
} else {
if (board === true && boardname === '') {
$('#pinterest-gallery').append('<p>Error: Please specify a boardname.</p>');
}
url = urlPrefix + username +'/'+ boardname + '.rss&num='+thumbnailCount;
}
}
$.ajax({
url: url,
dataType: 'jsonp',
success: function(data) {
$.each(data.responseData.feed.entries, function(i) {
var feedData = data.responseData.feed.entries;
var title = feedData[i].title;
var link = feedData[i].link;
var content = feedData[i].content;
var beginImageUrl = content.indexOf('http');
var endImageUrl = content.indexOf('"></a>');
var fullImageUrl = content.substring(beginImageUrl, endImageUrl);
var imageLink = $('<li><a class="pinterest-link" href="'+link+'">'+title+'</a></li>');
if (newWindow === true) {
$('.pinterest-link').attr('target', '_blank');
}
imageLink.appendTo('#pinterest-gallery').css('background-image','url(' + fullImageUrl + ')');
});
}
});
});
</script>
<!-- END CODE IT PRETTY PINTEREST GALLERY-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.