Blogger Auto Read more with thumbnail
Not too long ago I wrote a tutorial on how to make a “conventional” read more or expandable post. This time we will make an auto read more with thumbnail. Before we proceed, let me highlight the differences between conventional and auto read more.
(Blogger’s own read more -the jump break, can be classified as conventional read more)
Conventional read more vs. auto read more
| Conventional read more | Auto read more with thumbnail |
| Uses HTML | Javascript |
| Need to insert code in post. | Post is untouched. |
| Length of each snippet can be customized. | Length can be changed, but it affects all posts. |
| Read More is applied only to posts with the code added. | Read More applied to all posts, no exception. |
| No thumbnail. To show picture, you must place the picture inside the snippet (at the beginning of post). | The first picture in each post will be used as a thumbnail. You can also choose not to show thumbnail. |
| The code loads full post but only shows the snippet. | Only loads the snippet. |
Applying auto read more
Here we go:
- Login to your Blogger account.
- Go to Dashboard > Layout > Edit HTML.
- Back up your template.
- Check the Expand Widget Templates check box on top right of the HTML window.
- In the code window, look for
</head>line. - Add the Read More code below right after that line.
<!-- Auto read more script Start --> <b:if cond='data:blog.pageType != "item"'> <script type='text/javascript'> var thumbnail_mode = "yes"; //yes -with thumbnail, no -no thumbnail summary_noimg = 430; //summary length when no image summary_img = 340; //summary length when with image img_thumb_height = 200; img_thumb_width = 200; </script> </b:if> <script type='text/javascript'> //<![CDATA[ function removeHtmlTag(strx,chop){ if(strx.indexOf("<")!=-1) { var s = strx.split("<"); for(var i=0;i<s.length;i++){ if(s[i].indexOf(">")!=-1){ s[i] = s[i].substring(s[i].indexOf(">")+1,s[i].length); } } strx = s.join(""); } chop = (chop < strx.length-1) ? chop : strx.length-2; while(strx.charAt(chop-1)!=' ' && strx.indexOf(' ',chop)!=-1) chop++; strx = strx.substring(0,chop-1); return strx+'...'; } function createSummaryAndThumb(pID){ var div = document.getElementById(pID); var imgtag = ""; var img = div.getElementsByTagName("img"); var summ = summary_noimg; if(thumbnail_mode == "yes") { if(img.length>=1) { imgtag = '<span style="float:left; padding:0px 10px 5px 0px;"><img src="'+img[0].src+'" width="'+img_thumb_width+'px" height="'+img_thumb_height+'px"/></span>'; summ = summary_img; } } var summary = imgtag + '<div>' + removeHtmlTag(div.innerHTML,summ) + '</div>'; div.innerHTML = summary; } //]]> </script> <!-- Auto read more script End --> - After that, find this line:
<data:post.body/> - Replace the line with this code:
<!-- Auto read more Start --> <!-- http://BloggerSentral.blogspot.com --> <b:if cond='data:blog.pageType == "item"'> <data:post.body/> <b:else/> <div expr:id='"summary" + data:post.id'><data:post.body/></div> <script type='text/javascript'> createSummaryAndThumb("summary<data:post.id/>"); </script> <a class='more' expr:href='data:post.url'>Read more ...</a> </b:if> <!-- Auto read more End -->
- Click Preview. If it works, then click Save Template.
Customizing the snippet
You can customize the read more by changing the values of the variables below:
thumbnail_mode–set to “yes” if you want to show thumbnail with text summary. Set to other than “yes” to show only text summary.summary_img–specify the number of characters (including spaces) you want to show in the summary, with thumbnail.summary_noimg–specify the number of characters (including spaces) you want to show in the summary, when there is no thumbnail.img_thumb_heightandimg_thumb_width-specify the thumbnail height and width (in pixels).- You can change the words “Read more” with your own by changing it in line 9 of the code in step 8.
That’s it, enjoy!
Before you leave:
- Do you find this article useful? Share it via Tweet This or Add This buttons below.
- Any suggestion, question or comment? Please post it in the comments below.

































16 comments to "Blogger Auto Read more with thumbnail"
A reader asked how to apply auto read more only on archive and labels page. Here is the answer,
In step 8, insert this code after line 5:
[b:if cond='data:blog.url == data:blog.homepageUrl']
[data:post.body/]
[b:else/]
and
[/b:if] after line 10.
Replace "[]" with "<>".
Excellent ! You are first blogger that helped me with that problem. I tried to contact authors of those scripts and no one answered.
I got this to work, on both labels pages and archive pages, just like i want. But (!) i already have bloggers "read more" option enabled and used on every page, so, when i add your piece of code, it shows me two "read more" links. Posts without bloggers --more-- tag works just fine. You can check my test blog here http://novitest.blogspot.com/2009_11_01_archive.html and see how first post have two "read more" links.
Thanks once again. Best regards
Саша Стефановић,
Here's my suggestion:
1. Use the original auto read more code in step 8, without modification. What this will do is applies read more to all pages, except individual pages.
2. Preventing duplicate read more's. If you don't want to go back to your posts and remove Blogger jumpbreak one by one, you can simply disable it. Here's how,
Find this code inside your template:
[b:if cond='data:post.hasJumpLink']
[div class='jump-link']
[a expr:href='data:post.url + "#more"'][data:post.jumpText/][/a]
[/div]
[/b:if ]
just remove it or enclose it in comments tag, like this:
[!--
the code in here
--]
Replace "[]" with "<>".
OK, that can be done that way too. But the problem is with my main blog where i want to implement this. http://svuci.blogspot.com. As you can see, I put image first, then one (two, three or more) sentence and then I put <-more-> blogger tag. So, if user what to read more, he can click there and he have whole post.
So, if i implement your hack for "show more" i need to put exact limit of number of characters to show before "read more" link (or i'm wrong). So, this isn't best option for me now.
I would be happy if I can continue to work with bloggers hack for "more" option only on index page (main blogger page), and use your hack on archive and labels pages.
This sounds too much complicated, but i think it's possible somehow.
Саша Стефановић,
Now we're at it, it's not complicated at all. Just add a conditional tag in Blogger jumpbreak code so that it will only be active on homepage. Like this:
[b:if cond='data:blog.url == data:blog.homepageUrl']
[b:if cond='data:post.hasJumpLink']
[div class='jump-link']
[a expr:href='data:post.url + "#more"'][data:post.jumpText/][/a]
[/div]
[/b:if ]
[/b:if ]
I think that should do it.
Eh ... that's what i'm talking about. This works excellent. Thank you, thank you, thank you.
Big *thumbs up* for you.
Maybe you should write new tutorial with how to do this. I found many people asking on different blogs/forums this same thing.
THANK YOU !!!
excellent tutorial. now my blog look more professional than before.
thank you very much
Hi i copied the code as per your instructions, but i am not able to get it to work. Don't know where i am going wrong. Please do check out http://a2zvegetariancuisine.blogspot.com/, thanks in advance.
Sorry got it to work, one question if i want to expand the space meaning if you check out my blog you will understand. It is kind of cramped and also can i put email me or other icons in thumbnail itself.
A 2 Z Vegetarian Cuisine,
I agree it does look cramped. May I suggest other ways to make it less crampy?
1. Lose the border lines in the main column.
2. Move the bookmark button to be in the same line as the email link.
3. Align post footer and Adsense link with the post.
4. Adjust vertical margins to "loosen" the post area.
5. You made a label out of post tile. Is that necessary?
That's just my two cents. If you need help doing any of those, post here or email me.
I just wanted to say - THANK YOU :) Works perfectly on my blog.
My pleasure Loveena :)
I've following all the step but result this error messages
Your template could not be parsed as it is not well-formed. Please make sure all XML elements are closed properly.
XML error message: The value of attribute "type" associated with an element type "null" must not contain the '<' character.
what's wrong?? please help me..
Jerry H,
Did you copy the code correctly? As explained in FAQs?
Yes, I've copy the script from
until
is the template affect this script?
I use Tic Tac template..
Jerry H,
This code should work on any template.
Now it's your turn to say something