Home » » Recent Posts Image Gallery For Blogger

Recent Posts Image Gallery For Blogger

I notice a growing trend towards using pictures to link to posts. Pinterest effect perhaps? Anyway, some people code the pictures listing manually in a HTML/Javascript gadget to form a gallery, while others painstakingly add one picture at a time using a Picture gadget. It's a pain.
But there is a good news: you can now list the pictures easily andautomatically using our recent posts image gallery widget. Perfect for listing recipes, design projects and other photo-centric posts.
blogger recent posts image gallery

Below are some the features of the gallery:
  • You can set your preferred image size, any size. Image will come out sharp, no pixelation.
  • Light -what you see is what actually loaded. Most image galleries take forever to load because they load full size images and then shrink them using CSS. This gallery loads the correct image size the first time.
  • Posts can be filtered using a label.
  • Support multiple galleries. The options (thumb size and post title overlay) can be set independently for each gallery.


  1. First go to Template > Edit HTML and add this script before the </head>tag in your template.
    02// Blogger Recent Posts Gallery by Bloggersentral.com
    03// Tutorial at http://www.bloggersentral.com/2013/05/recent-posts-image-gallery-for-blogger.html
    04// Free to use or share, but please keep this notice intact.
    06function bsrpGallery(root) {
    07    var entries = root.feed.entry || [];
    08    var html = ['<div class="bsrp-gallery nopin" title="Get this from BloggerSentral.com">'];
    09    for (var i = 0; i < entries.length; ++i) {
    10        var post = entries[i];
    11        var postTitle = post.title.$t;
    12        var orgImgUrl = post.media$thumbnail ? post.media$thumbnail.url : 'http://3.bp.blogspot.com/-sWtp_qRPNT8/UZYmQq5sAdI/AAAAAAAAEec/7YDbpK4Q6g8/s72-c/default+image.png';
    13        var newImgUrl = orgImgUrl.replace('s72-c', 's' + bsrpg_thumbSize + '-c');
    14        var links = post.link || [];
    15        for (var j = 0; j < links.length; ++j) {
    16            if (links[j].rel == 'alternate') break;
    17        }
    18        var postUrl = links[j].href;
    19        var imgTag = '<img src="' + newImgUrl + '" width="' + bsrpg_thumbSize + '" height="' + bsrpg_thumbSize + '"/>';
    20        var pTitle = bsrpg_showTitle ? '<span class="ptitle">' + postTitle + '</span>' : '';
    21        var item = '<a href="' + postUrl + '" target="_blank" title="' + postTitle + '">' + imgTag + pTitle + '</a>';
    22        html.push('<div class="bs-item">', item, '</div>');
    23    }
    24    html.push('</div>');
    25    document.write(html.join(""));
  2. Then, add the following CSS code into the CSS section of your template (right before </b:skin> tag).
    1/* BloggerSentral Recent Posts Image Gallery CSS Start */
    2.bsrp-gallery {padding:10pxclear:both;}
    3.bsrp-gallery:after {content"";display: table;clear:both;}
    4.bsrp-gallery .bs-item a {position:relative;float:left;margin0 15px 15px 0!important;text-decoration:none;}
    5.bsrp-gallery .bs-item .ptitle {background: rgba(000,0.5); background#7f7f7f\9displayblockclearleft;font-size11pxline-height:1.3emheight2.6em;positionabsolutetext-alignleftbottom10%;color:#fffpadding:2px 5px; word-wrap: break-word;overflow:hidden;}
    6.bsrp-gallery a img {background#eeefloatleft;padding5px; box-shadow: 1px 1px 3px rgba(0000.5); -moz-box-shadow: 1px 1px 3px rgba(0000.5); -webkit-box-shadow: 1px 1px 3px rgba(0000.5); transition: background-color 0.4s; -webkit-transition: background-color 0.4s; -moz-transition: background-color 0.4s;}
    7.bsrp-gallery a:hover img {background#ee7e22;}
    8/* BloggerSentral Recent Posts Image Gallery CSS End */
    If you prefer to put the CSS together with the scripts (in a post or in a HTML/Javascript gadget), you must enclose it in a </script> tag.
  3. Finally add this script wherever you want the gallery to appear. It can be added anywhere -in a post, a page or a HTML/Javascript widget.
    2  var bsrpg_thumbSize = 150;
    3  var bsrpg_showTitle = true;
    5<script src="/feeds/posts/summary?max-results=8&alt=json-in-script&callback=bsrpGallery"></script>
    • Set the image size (in pixel) in line 2.
    • Set line 3 to true to add post title overlay on each image. False will display image without overlay. However, in both cases, the post title will appear in the tooltip that pops up when you hover the image.
    • To display recent posts under a label (e.g. RECIPE), replace the base URL for the src attribute with the label feed URL, like so:
    • Set the number of posts to be displayed by changing the value of max-results query parameter.


Below are two live demo galleries.
This one shows the latest 10 posts from Blogger Sentral's general feed (/feeds/posts/summary). Image size is set to 100px, and post title overlay is set to false.
This one displays the latest 6 posts from Blogger Sentral's "widgets" label feed (/feeds/posts/summary/-/widgets). Image size is set to 140px, and post title overlay is set to true.



Post a Comment

Translate This Blog's Article

Related Posts Widget