Saturday 7 March 2009

Automatic Thumbnail and Readmore Function

Readmore function is used to cut our post on homepage, post will appear fully when we click readmore link. You can see my post on homepage. It's cut automatically and if we insert image, it appears thumbnail. This is automatic readmore function with thumbnail. We just need to set up our HTML code. How to?

1. Go to "Layout" click "Edit HTML"
2. Tick on "Expand Widget Templates"
3. Find </head> code
4. Insert this javascript under </head> code

<script type='text/javascript'>var thumbnail_mode = &quot;no-float&quot; ;
summary_noimg = 430;
summary_img = 340;
img_thumb_height = 100;
img_thumb_width = 120;
</script>
<script src='http://cebong.ipit.googlepages.com/read-moreotomatis.js' type='text/javascript'/>




Note :

You can cutomize this size

summary_noimg = 430; is post cut height without image
summary_img = 340; is post cut height with image
img_thumb_height = 100; is thumbnail image height
img_thumb_width = 120; is thumbnail image width

5. Find this code

<data:post.body/>



6. Replace with this code below

<b:if cond='data:blog.pageType != &quot;item&quot;'>

<div expr:id='&quot;summary&quot; + data:post.id'><data:post.body/></div>
<script type='text/javascript'>createSummaryAndThumb(&quot;summary<data:post.id/>&quot;);</script>
<span class='rmlink' style='float:right;padding-top:20px;'><a expr:href='data:post.url'> read more &#8220;<data:post.title/>&#8221;</a></span>

</b:if>
<b:if cond='data:blog.pageType == &quot;item&quot;'><data:post.body/></b:if>



7. Save


Now you can try to post and it cut automatically.

Note :

Please save javascript , here's the URL, http://cebong.ipit.googlepages.com/read-moreotomatis.js, upload to your own filehosting. I can't guarantee if my bandwidth exceeded :D

or download readmore-otomatis-script here

After upload script to your own hosting, replace http://cebong.ipit.googlepages.com/read-moreotomatis.js to your own URL javascript
Source : Kang Jaloee Punya
Digg Google Bookmarks reddit Mixx StumbleUpon Technorati Yahoo! Buzz DesignFloat Delicious BlinkList Furl

0 comments: on "Automatic Thumbnail and Readmore Function"

Post a Comment