Create Image Thumbnail Your Post on Widget/sidebar|NETTER KINGDOM Create Image Thumbnail Your Post on Widget/sidebar

Wednesday, May 12, 2010

Create Image Thumbnail Your Post on Widget/sidebar


Posting this time will explain how to make a thumbnail in blogger post . like this example:

Steps you should do is:
1. Open your Blogger.
2. click on "Layout"
3. On the Elements page, find where you will put your post tumbnail.
4. Then click on "add a gadget"
5. Select "HTML / JavaScript"
6. copypaste scrip code below:

<script language="JavaScript">
imgr = new Array();

imgr[0] = "http://3.bp.blogspot.com/_ieMMucroqWY/S2LN_imgI0I/AAAAAAAAAVA/vX6V--4BA-w/S1600-R/No+image.jpg";

showRandomImg = true;

aBold = true;

summaryPost = 0; //
summaryTitle = 80; //

numposts = 4; //
home_page = "http://your-url.com/";

label1 = "your label"; //change this to your desired label name
tLabel1 = "your label"; //change this to your desired label name

function removeHtmlTag(strx,chop){
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);
}
}
s = s.join("");
s = s.substring(0,chop-1);
return s;
}

function showrecentposts(json) {
j = (showRandomImg) ? Math.floor((imgr.length+1)*Math.random()) : 0;
img = new Array();

for (var i = 0; i < numposts; i++) {
var entry = json.feed.entry[i];
var posttitle = entry.title.$t;
var pcm;
var posturl;
if (i == json.feed.entry.length) break;
for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'alternate') {
posturl = entry.link[k].href;
break;
}
}

for (var k = 0; k < entry.link.length; k++) {
if (entry.link[k].rel == 'replies' && entry.link[k].type == 'text/html') {
pcm = entry.link[k].title.split(" ")[0];
break;
}
}

if ("content" in entry) {
var postcontent = entry.content.$t;}
else
if ("summary" in entry) {
var postcontent = entry.summary.$t;}
else var postcontent = "";

postdate = entry.published.$t;

if(j>imgr.length-1) j=0;
img[i] = imgr[j];

s = postcontent ; a = s.indexOf("<img"); b = s.indexOf("src=\"",a); c = s.indexOf("\"",b+5); d = s.substr(b+5,c-b-5);

if((a!=-1)&&(b!=-1)&&(c!=-1)&&(d!="")) img[i] = d;

//cmtext = (text != 'no') ? '<i><font color="'+acolor+'">('+pcm+' '+text+')</font></i>' : '';


var month = [1,2,3,4,5,6,7,8,9,10,11,12];
var month2 = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

var day = postdate.split("-")[2].substring(0,2);
var m = postdate.split("-")[1];
var y = postdate.split("-")[0];

for(var u2=0;u2<month.length;u2++){
if(parseInt(m)==month[u2]) {
m = month2[u2] ; break;
}
}

//var daystr = (showPostDate) ? '<i><font color="'+acolor+'"> - ('+day+ ' ' + m + ' ' + y + ')</font></i>' : "";

posttitle = (aBold) ? ""+posttitle+"" : posttitle;

var trtd = '<li class="art-BlockContent-body"style="list-style:none;margin-bottom:0.4em;margin-top:-0.4em; margin-left:0em;padding-left:0em;text-indent:0em;"><div class="entry"> <div style="margin: 5px; overflow: hidden; height: 65px;"><a style="font-size: 16px; font-weight: bold;" title="'+posttitle+'" href="'+posturl+'"><img class="post_thumbnail thumbnail thumbnail post_thumbnail" style="float:left; margin:0px 2px 0px 0px; cursor:pointer; cursor:hand; border:0" height="65px" width="60px" src="'+img[i]+'"></a><h4 class="post-title" style="margin: 0pt; padding: 0pt; text-align: left;"> <a href="'+posturl+'">'+removeHtmlTag(posttitle,summaryTitle)+'</a> </h4>'+removeHtmlTag(postcontent,summaryPost)+'</div></div> <p class="sp-separator"> </p></li> ';

document.write(trtd);


j++;
}

}

//document.write('<li class="t"><h2 class="t">'+Title1+'</h2><div class="sp-read-more"><a href="'+home_page+'search/label/'+label1+'?max-results=10">more >></a></div><div style="margin: 0pt; padding: 0pt; clear: both; height: 0pt;"></div></li>');
document.write("<script src=\""+home_page+"feeds/posts/default/-/"+label1+"?max-results="+numposts+"&orderby=published&alt=json-in-script&callback=showrecentposts\"><\/script>");

</script> <a href='http://your-url.com/search/label/your-label-here?max-results=10' rel='bookmark'>Read More Posts From This Category</a>




Notes For Script:
  1. You can upload images tumbnail type (no-image) of your own by replacing the url on imgr[0] or let it remain like that.
  2. You can change length setting for your article summary and tittle sumary on
    summaryPost = 0; // ----> 0 = calculated per-word
    summaryTitle = 80; //----> 80 = calculated per-word
  3. You may change for number of your post on such as 4, 5 7 8 etc. in numposts = 4; //
  4. You must change this with your URL ---> home_page = "http://your-url.com/";
  5. You must change for your label for example : automotive. That must be same label. Change on code : label1 = "your label"; tLabel1 = "your label";
  6. You may change for Thumnail area, Code here : <div style="margin: 5px; overflow: hidden; height: 65px; ---->change value for height.
  7. You may change for widht and height for your thumnail image. Code here : style="float:left; margin:0px 2px 0px 0px; cursor:pointer; cursor:hand; border:0" height="65px" width="60px"
Good Luck ... !!!
Netter Kingdom


Comments :

4 komentar to “Create Image Thumbnail Your Post on Widget/sidebar”

Asp Net Developer said...
on 

Thanks.. I will surly try it

fairy tail episode 30 said...
on 

Thanks had no idea how to do this

business logo design said...
on 

Thanks A lot such a useful guide.

Rackmount LCD said...
on 

Very nice information. I am thankful for it.

Post a Comment

Please don`t spaming !
Please do not put a link in the comments box. Author of comments have been getting backlinks from this blog.
I will deleted if your comment is spam or put your link IN THE COMMENTS BOX !!!
Have a nice day my friend... :D

Top Commenters