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 and automatically using our recent posts image gallery widget. Perfect for listing recipes, design projects and other photo-centric posts.
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
- First go to Template > Edit HTML and add this script before the
</head>
tag in your template.<script> // Blogger Recent Posts Gallery by Bloggersentral.com // Tutorial at http://www.bloggersentral.com/2013/05/recent-posts-image-gallery-for-blogger.html // Free to use or share, but please keep this notice intact. //<![CDATA[ function bsrpGallery(root) { var entries = root.feed.entry || []; var html = ['<div class="bsrp-gallery nopin" title="Get this from BloggerSentral.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 : 'https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjzhy8QJb5qheHFi-RxJJHmNSMO9aJZlK5M66_fzppTay7DABdbUatVGobXhZzERLSoEu9PV_Sn8OJ94X88rUKIe2L07GBXoMrGDRm-maJWqNEN-bzY1Q4mObAbbJM5D3MoHf049hHW7ZcJ/s72-c/default+image.png'; var newImgUrl = orgImgUrl.replace('s72-c', 's' + bsrpg_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="' + bsrpg_thumbSize + '" height="' + bsrpg_thumbSize + '"/>'; var pTitle = bsrpg_showTitle ? '<span class="ptitle">' + postTitle + '</span>' : ''; var item = '<a href="' + postUrl + '" target="_blank" title="' + postTitle + '">' + imgTag + pTitle + '</a>'; html.push('<div class="bs-item">', item, '</div>'); } html.push('</div>'); document.write(html.join("")); } //]]> </script>
-
Then, add the following CSS code into the CSS section of your template (right before
</b:skin>
tag)./* BloggerSentral Recent Posts Image Gallery CSS Start */ .bsrp-gallery {padding:10px; clear:both;} .bsrp-gallery:after {content: "";display: table;clear: both;} .bsrp-gallery .bs-item a {position: relative;float:left;margin: 0 15px 15px 0 !important;text-decoration:none;} .bsrp-gallery .bs-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;} .bsrp-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;} .bsrp-gallery a:hover img {background: #ee7e22;} /* 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. -
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 bsrpg_thumbSize = 150; var bsrpg_showTitle = true; </script> <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:/feeds/posts/summary/-/RECIPE
- Set the number of posts to be displayed by changing the value of
max-results
query parameter.
Demo
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.
Enjoy!
52 comments to "Recent Posts Image Gallery For Blogger"
Loved!!!
Love it but the post titles are not overlaying for me, they show up on the side. The thumbnails also won't go next to each other, no matter how small I make them they always show stacked on top of each other with means lots of white space. (Even if I set the post titles to false.) Can you help?
Very cool, I'll try it soon, thank you master
nice share GL. sure blogspot user will love to try this
Thank you! I would really like something similar for Popular Posts too!
Any help?? Would love to use it but not with the formatting the way it is...
Could you please help me to make /feeds/posts/summary url in my blog?
@Jon Thorsen
Install it and give me the URL. I need to see it live.
It is... http://ReverseWineSnob.com
On the right sidebar near the bottom.
@Jon Thorsen
There is a missing closing curly bracket for "#AdSense1" selector in your CSS, here:
#blog-pager-older-link {padding:5px;font-size:90%;width:200px;text-align:right;}#AdSense1{
text-align:center;
/* BloggerSentral Recent Posts Image Gallery CSS Start */
.bsrp-gallery {padding:10px; clear:both;}
Nice share on this one. Pinterest really is having an effect across the web. Just look at G+ and their new interface.
Ugh, yes, thank you Greenlava! That fixed it, much better now!!
I've tried to place the gallery on a static page, which is my homepage but the post titles are not overlaying for me too, they show up on the side.
The thumbnails also won't go next to each other, they show stacked on top of each other.
How can I fix this?
by the way, can you recommend a cool and simple slider for the same page?
Thanks
Botão Doce
Hi! Love all your tips. This is working pretty good for me, except there is some html script appearing at the top of my blog. Why is it showing up there?
Gina
http://www.ginascraftcorner.blogspot.com
@Gina Wamsley
Where is it?
Thank you for sharing an amazing tutorial to set up gallery widget.
bro ur widget is awesome. I am impressed..thanks for sharing.
That was so darn easy to understand thank you. I've currently got it in my footer widget but would love it to be centralised because at the moment it's to the left. How do I do this ??
Also I have a rich snippet and breadcrumb bit of data to put in my template but don;t have a clue where it should go ??
Please have a look at my site and give me some advice
http://www.enochandplonk.com
Thanks so much
Nicola x
Thanks it works for me.
But how can I maximize the paragraph length hovering on the image.
Thanks Again.
Nice one! Thanks for sharing this awesome tutorial. I already installed this on my blog and now want to show random post instead of recent post. Any help?
I love this but I am confused on how to change max-results because I only want 5 to show up. Would highly appreciate it if you could please tell me.
Please disregard my previous comment as I have figured it out. Can this be done to popular posts though? And thank you for helping those of us that can edit/add HTML but cannot build it. Much appreciated.
Wonderful!
Thanks a LOT !
Thanks soooooo much for this! You don't even know how long it took me to find this! It's perfect!
Thanks soooooo much for this
Just want to say thank you - your tutorials are absolutely fantastic and in the space of half an hour my blog has got exponentially better!
Rachael
Finally, something that I have been looking for!
Just customized by blog. Check http://orgolyo.blogspot.com/
Thanks!
error message
Error parsing XML, line 3575, column 52: The reference to entity "alt" must end with the ';' delimiter.
wow..thanks so much your posts have been a great help for me today and I'm enjoying applying them to my blogger
much love..
worked a treat. Is there anyway to select which image from the post is displayed in the gallery ?
Great widget,but on my blog some titles of the posts which are shown in the gadget aren centered and the background isn't 100% wide: http://iamtimblog.blogspot.com
I have no problem getting the full feed to show, but I am having no luck with the labels feed. One of my labels is Appetizers. Should the code read:
script src="/feeds/posts/summary/-/Appetizers?max-results=200&alt=json-in-script&callback=bsrpGallery"
????????
@Nicola Thomas
It defaults to the first image in the post. Can't change that :(
@iamtimblogger
I don't see any of the problems you mentioned. Have you fixed them?
@Becky
The code looks good.
Very nice thanx for this i will try it on my blog in future
Thank you for this
I am echoing a comment from above that I did not see a response to "Could you please help me to make /feeds/posts/summary url in my blog?"
I have no clue how to actually format my address correctly. My feedburner url is: http://feeds.feedburner.com/therookiecook/wLnZ
I am trying to load this onto a test site but I can't get anything to show up.
Thanks so much!!
Never mind, I figured it out - thanks! You are a genius!! I currently am using inlinkz for my photo gallery but it is super annoying to have to update all the time and I never remember to do it. I absolutely love this, thanks again!
............feeds/posts/summary?max-results=8&alt=json-in-script&callback=bsrpGallery...
Really great work but i need only one thing that I want to callback from particular array number to another, Means like 'maxresult=20'(condition) in callback function. I need callback code to show recent posts from Particular array number like this i=9 to i=15. So please let me know that it is possible to callback from particular array number to another.
Wow this is great! But how do you make it so that it shows older posts instead of the most recent posts?
I REALLY need help. I try to follow all the steps but on the Step#3 i don't know where to locate the script.
I'd like to replace the default image to my own picture from the recent post.
Here is my blog: http://elenalitsova.blogspot.co.uk
Thank you in advance
Elena
@Elena Litsova PHOTOGRAPHY
I notice you host your images on Photobucket.
I'm sorry but this widget only works with images hosted on Picasaweb ie. images uploaded via Blogger post editor, Google+ or Picasaweb website.
@Ram V
Use "start-index" query. If you want to get the 9th until the 15th posts, use this:
feeds/posts/summary?start-index=9&max-results=7&alt=json-in-script&callback=bsrpGallery
(max-result is set at 15-9 +1 which equals to 7)
@Emme E
You can select older posts using the start-index method I described above.
Thanks Greenlava it was a great turorial.
Just wanted to know one thing. There is an option to either hide or display the post title but is there any workaround to show the title in a small window when hovering over the thumbnail ? Or maybe the title appearing when you hover over the image?
I am using the code and its working fine, however, with the title display: on, the image completely gets covered.
Thanks in advance
Hi!
Thanks for this upload.
Is it possible to center the gallery? Like, have a two columns centered on the page...
Thanks in advance.
Romeu
how to put this widget in homepage only? because this widget shows also on page? what should I do?
It worked like a Charm on my Picutres blog --> http://www.images.christmasabbottblog.com
I had been searching to create a gallery homepage for it and finally my search ended.
Is there any way by which I can make this widget to choose posts (load posts) randomly everytime the page refreshes instead of the default ordered post sequence ?
THanks
@Jerahmeel Barlaan
That is explained here: Display/hide widget on specific pages in Blogger
@Kashish Jain
Sorry but at this time the answer is no.
I've been looking for this for soo long. Thank you very much :)
Easy to install and light too. Thanks
Instead of using plugins we can use the code to reduce our loading speed which this code really great for displaying image gallery on my blog
Comments on this post are closed.