Blogger widgetlarından 'rasgele gönderiler'(Random Posts) genellikle resimde ki gibi küçük görsel'li olarak gelir.
Kodları değiştirip boyutlarını(width/height) yükselttiğimizde görselde ki çözünürlük düşük olarak karşımıza çıkar. Bu da çok kötü bir görüntüye neden olur. Şimdi bu durumun önüne geçmek için ufak bir değişiklik yapıp eklentimizi istediğimiz hale getirelim. Şimdi farzedelim ki Blogger Kontrol Paneli > Yerleşim > Rasgele Gönderiler (Random Posts) Eklentisi aşağıda verilen gibi olsun;
<div id='random-posts'>
<script type='text/javaScript'>
var randomposts_number = 10;
var randomposts_chars = 0;
var randomposts_details = 0;
var randomposts_comments = 'Comments';
var randomposts_commentsd = 'Comments Disabled';
var randomposts_current = [];
var total_randomposts = 0;
var randomposts_current = new Array(randomposts_number);
function randomposts(json) {
total_randomposts = json.feed.openSearch$totalResults.$t
}
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=randomposts\"><\/script>');
function getvalue() {
for (var i = 0; i < randomposts_number; i++) {
var found = false;
var rndValue = get_random();
for (var j = 0; j < randomposts_current.length; j++) {
if (randomposts_current[j] == rndValue) {
found = true;
break
}
};
if (found) {
i--
} else {
randomposts_current[i] = rndValue
}
}
};
function get_random() {
var ranNum = 1 + Math.round(Math.random() * (total_randomposts - 1));
return ranNum
};
</script>
<script type='text/javaScript'>
function random_posts(json) {
for (var i = 0; i < randomposts_number; i++) {
var entry = json.feed.entry[i];
var randompoststitle = entry.title.$t;
if ('content' in entry) {
var randompostsnippet = entry.content.$t
} else {
if ('summary' in entry) {
var randompostsnippet = entry.summary.$t
} else {
var randompostsnippet = "";
}
}
randompostsnippet = randompostsnippet.replace(/<[^>]*>/g, "");
if (randompostsnippet.length < randomposts_chars) {
var randomposts_snippet = '<div class="random-summary">' + randompostsnippet + '</div>';
} else {
randompostsnippet = randompostsnippet.substring(0, randomposts_chars);
var whitespace = randompostsnippet.lastIndexOf(" ");
var randomposts_snippet = randompostsnippet.substring(0, whitespace) + "…";
randomposts_snippet = '<div class="random-summary">' + randomposts_snippet + '</div>';
}
for (var j = 0; j < entry.link.length; j++) {
if ('thr$total' in entry) {
var randomposts_commentsnum = entry.thr$total.$t + ' ' + randomposts_comments
} else {
randomposts_commentsnum = randomposts_commentsd
}
if (entry.link[j].rel == 'alternate') {
var randompostsurl = entry.link[j].href;
var randomposts_date = entry.published.$t;
if ('media$thumbnail' in entry)
{
var randompoststhumb = entry.media$thumbnail.url
}
else if ( entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/))
{
// how to resize this external image ?
randompoststhumb = entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/)[1];
// like using 'resizeImage' function in blogger includable expr:
// randompoststhumb = resizeImage(randompoststhumb, 280, "280:152")
} else {
randompoststhumb = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDRZeLdrnC3zIH8jlShD6zOvQYfYjlU8li54qjGZFr5SNmsW_-YhZHyxscaHgvL3hmI6VCQ9trp598p9oKShmzdxeD8I-MSkix-W2muijsIAtCm_CiCXj9Rif2lKiR2HnifvQjN2gXph4/s1600/no_thumb.png"
}
}
}
document.write('<div class="randomPost">');
document.write('<a href="' + randompostsurl + '" rel="nofollow">' + '<span class="imgf"><span src="' + randompoststhumb + '"></span></span>' + randompoststitle + '</a>');
if (randomposts_details) {
document.write('<span><div class="random-info">' + randomposts_date.substring(8, 10) + '.' + randomposts_date.substring(5, 7) + '.' + randomposts_date.substring(0, 4) + ' - ' + randomposts_commentsnum) + '</div></span>'
}
if (randomposts_chars) {
document.write(randomposts_snippet);
}
document.write('</div>');
}
}
getvalue();
for (var i = 0; i < randomposts_number; i++) {
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index=' + randomposts_current[i] + '&max-results=1&callback=random_posts\"><\/script>')
}
</script>
</div>
<script type='text/javaScript'>
var randomposts_number = 10;
var randomposts_chars = 0;
var randomposts_details = 0;
var randomposts_comments = 'Comments';
var randomposts_commentsd = 'Comments Disabled';
var randomposts_current = [];
var total_randomposts = 0;
var randomposts_current = new Array(randomposts_number);
function randomposts(json) {
total_randomposts = json.feed.openSearch$totalResults.$t
}
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&max-results=0&callback=randomposts\"><\/script>');
function getvalue() {
for (var i = 0; i < randomposts_number; i++) {
var found = false;
var rndValue = get_random();
for (var j = 0; j < randomposts_current.length; j++) {
if (randomposts_current[j] == rndValue) {
found = true;
break
}
};
if (found) {
i--
} else {
randomposts_current[i] = rndValue
}
}
};
function get_random() {
var ranNum = 1 + Math.round(Math.random() * (total_randomposts - 1));
return ranNum
};
</script>
<script type='text/javaScript'>
function random_posts(json) {
for (var i = 0; i < randomposts_number; i++) {
var entry = json.feed.entry[i];
var randompoststitle = entry.title.$t;
if ('content' in entry) {
var randompostsnippet = entry.content.$t
} else {
if ('summary' in entry) {
var randompostsnippet = entry.summary.$t
} else {
var randompostsnippet = "";
}
}
randompostsnippet = randompostsnippet.replace(/<[^>]*>/g, "");
if (randompostsnippet.length < randomposts_chars) {
var randomposts_snippet = '<div class="random-summary">' + randompostsnippet + '</div>';
} else {
randompostsnippet = randompostsnippet.substring(0, randomposts_chars);
var whitespace = randompostsnippet.lastIndexOf(" ");
var randomposts_snippet = randompostsnippet.substring(0, whitespace) + "…";
randomposts_snippet = '<div class="random-summary">' + randomposts_snippet + '</div>';
}
for (var j = 0; j < entry.link.length; j++) {
if ('thr$total' in entry) {
var randomposts_commentsnum = entry.thr$total.$t + ' ' + randomposts_comments
} else {
randomposts_commentsnum = randomposts_commentsd
}
if (entry.link[j].rel == 'alternate') {
var randompostsurl = entry.link[j].href;
var randomposts_date = entry.published.$t;
if ('media$thumbnail' in entry)
{
var randompoststhumb = entry.media$thumbnail.url
}
else if ( entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/))
{
// how to resize this external image ?
randompoststhumb = entry.content.$t.match(/\<img.+src\=(?:\"|\')(.+?)(?:\"|\')(?:.+?)\>/)[1];
// like using 'resizeImage' function in blogger includable expr:
// randompoststhumb = resizeImage(randompoststhumb, 280, "280:152")
} else {
randompoststhumb = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDRZeLdrnC3zIH8jlShD6zOvQYfYjlU8li54qjGZFr5SNmsW_-YhZHyxscaHgvL3hmI6VCQ9trp598p9oKShmzdxeD8I-MSkix-W2muijsIAtCm_CiCXj9Rif2lKiR2HnifvQjN2gXph4/s1600/no_thumb.png"
}
}
}
document.write('<div class="randomPost">');
document.write('<a href="' + randompostsurl + '" rel="nofollow">' + '<span class="imgf"><span src="' + randompoststhumb + '"></span></span>' + randompoststitle + '</a>');
if (randomposts_details) {
document.write('<span><div class="random-info">' + randomposts_date.substring(8, 10) + '.' + randomposts_date.substring(5, 7) + '.' + randomposts_date.substring(0, 4) + ' - ' + randomposts_commentsnum) + '</div></span>'
}
if (randomposts_chars) {
document.write(randomposts_snippet);
}
document.write('</div>');
}
}
getvalue();
for (var i = 0; i < randomposts_number; i++) {
document.write('<script type=\"text/javascript\" src=\"/feeds/posts/default?alt=json-in-script&start-index=' + randomposts_current[i] + '&max-results=1&callback=random_posts\"><\/script>')
}
</script>
</div>
Şimdi yukarıda ki kodun içerisinde CTRL ve F tuş kombinasyonu yardımıyla aşağıda ki kodları bulalım;
var randompoststhumb = entry.media$thumbnail.url
Bulduğumuz yukarıda ki kodların tamamını silip aşağıda ki kod ile değiştirelim.
var randompoststhumb = entry.media$thumbnail.url.replace("s72-c", "s0").replace("/default.jpg","/hqdefault.jpg");
randompoststhumb = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=' + randompoststhumb + '&container=focus&resize_w=300&resize_h=300&refresh=2592000';
İşte sonuç:randompoststhumb = 'https://images1-focus-opensocial.googleusercontent.com/gadgets/proxy?url=' + randompoststhumb + '&container=focus&resize_w=300&resize_h=300&refresh=2592000';
Ay ben uğraşamam ayol'cular için hazır kodu aşağıda ki linkte :)