Top Ad 728x90

header ads

Wednesday, 25 September 2013

, , ,

Customizable Recent Post Image Gallery for Blogger Blogs

We always see recent posts in blogs but usually it is in text forms, simple because many of the coded recent posts is another burden in page loading, in terms of design blogs that is conscious with their page load usually limit their scripts and Css design, Today I am giving you a filterable recent posts image gallery that will never add to your page load, and has a great css coding for adding spice to your blogs, 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.

We always see recent posts in blogs but usually it is in text forms, simple because many of the coded recent posts is another burden in page loading, in terms of design blogs that is conscious with their page load usually limit their scripts and Css design,

Today I am giving you a filterable recent posts image gallery that will never add to your page load, and has a great css coding for adding spice to your blogs, 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.

Customizable Recent Post Image Gallery for Blogger Blogs

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.

Installation

1. First go to Template > Edit HTML and add this script before the </head> tag in your template.
<script>
// Blogger Recent Posts Gallery by http://theblogger911.blogspot.com
// Tutorial at http://theblogger911.blogspot.com/2013/09/customizable-recent-post-image-gallery.html
// Free to use or share, but please keep this notice intact.
//<![CDATA[
function tb911rpGallery(root) {
var entries = root.feed.entry || [];
var html = ['<div class="tb911rp-gallery nopin" title="Get this from theblogger911.blogspot.com">'];
for (var i = 0; i < entries.length; ++i) {
var post = entries[i];
var postTitle = post.title.$t;
var orgImgUrl = post.media$thumbnail ? post.media$thumbnail.url : 'http://3.bp.blogspot.com/-sWtp_qRPNT8/UZYmQq5sAdI/AAAAAAAAEec/7YDbpK4Q6g8/s72-c/default+image.png';
var newImgUrl = orgImgUrl.replace('s72-c', 's' + tb911rpg_thumbSize + '-c');
var links = post.link || [];
for (var j = 0; j < links.length; ++j) {
if (links[j].rel == 'alternate') break;
}
var postUrl = links[j].href;
var imgTag = '<img src="' + newImgUrl + '" width="' + tb911rpg_thumbSize + '" height="' + tb911rpg_thumbSize + '"/>';
var pTitle = tb911rpg_showTitle ? '<span class="ptitle">' + postTitle + '</span>' : '';
var item = '<a href="' + postUrl + '" target="_blank" title="' + postTitle + '">' + imgTag + pTitle + '</a>';
html.push('<div class="tb911-item">', item, '</div>');
}
html.push('</div>');
document.write(html.join(""));
}
//]]>
</script>

2. Then, add the following CSS code into the CSS section of your template (right before </b:skin> tag).
/* www.theblogger911.blogspot.com Recent Posts Image Gallery CSS Start */
.tb911rp-gallery {padding:10px; clear:both;}
.tb911rp-gallery:after {content: "";display: table;clear: both;}
.tb911rp-gallery .tb911-item a {position: relative;float:left;margin: 0 15px 15px 0 !important;text-decoration:none;}
.tb911rp-gallery .tb911-item .ptitle {background: rgba(0, 0, 0, 0.5); background: #7f7f7f\9; display: block; clear: left; font-size: 11px; line-height:1.3em; height: 2.6em; position: absolute; text-align: left; bottom: 10%; color:#fff; padding:2px 5px; word-wrap: break-word; overflow:hidden;}
.tb911rp-gallery a img {background: #eee; float: left; padding: 5px; box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); -moz-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.5); transition: background-color 0.4s; -webkit-transition: background-color 0.4s; -moz-transition: background-color 0.4s;}
.tb911rp-gallery a:hover img {background: #ee7e22;}
/* www.theblogger911.blogspot.com 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</style> 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.
<script>
var tb911rpg_thumbSize = 150;
var tb911rpg_showTitle = true;
</script>
<script src="/feeds/posts/summary?max-results=8&alt=json-in-script&callback=tb911rpGallery"></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. SEO), replace the base URL for the src attribute with the label feed URL, like so:
    /feeds/posts/summary/-/SEO
    Set the number of posts to be displayed by changing the value of max-results query parameter.

    LIVE DEMOS


    This is set to 100px / false title /with 10max results This is set to 140px/ title true /with 8max results This is set to 90px/ true title/ 10max results/ summary/-/widgets Please leave a comment :)

    Top Ad 728x90