Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 1.91 KB  |  hits: 15  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. JavaScript for resizing photos in Blogger posts
  2. <img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 265px;" src="http://1.bp.blogspot.com/-y8j5IluAe4g/TykduAo1gnI/AAAAAAAAD38/K6VakbKwowU/s400/Czerwony%2BStompee%2Bdla%2Bdzieci.jpeg" alt="" id="BLOGGER_PHOTO_ID_5704123079323910770" border="0" />
  3.        
  4. <img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 556px;" src="http://1.bp.blogspot.com/-y8j5IluAe4g/TykduAo1gnI/AAAAAAAAD38/K6VakbKwowU/s556/Czerwony%2BStompee%2Bdla%2Bdzieci.jpeg" alt="" id="BLOGGER_PHOTO_ID_5704123079323910770" border="0" />
  5.        
  6. arrayofimgs = document.getelementsbytagname('img')
  7.  
  8. foreach arrayofimgs
  9.    if( strpos(img.src, 'blogspot.com') )
  10.        img.style.width='556px';
  11.        img.style.height='';
  12.        doSomeRegexOrManualStringManipulation(img.src, 's400', 's556')
  13.        
  14. <html>
  15. <head>
  16.  <script src="http://code.jquery.com/jquery-latest.js"></script>
  17. <script language="JavaScript">
  18.  $(document).ready(function(){
  19.    resizeImages();
  20.  });
  21.  
  22.  function resizeImages(){
  23.   var imageTags = document.getElementsByTagName("image");
  24.   if (!imageTags || imageTags.length <= 0)
  25.   {
  26.     imageTags = document.getElementsByTagName("img");
  27.   }
  28.   if(!imageTags){
  29.     return;
  30.   }
  31.   for(i = 0 ; i < imageTags.length; i++){
  32.  
  33.      imageTags[i].style.width="556px";
  34.  imageTags[i].style.height="";
  35.   }  
  36.  }
  37. </script>
  38. <head>
  39. <body>
  40. <image ...
  41. </body>
  42. </html>
  43.        
  44. <script type='text/javascript'>
  45.   /* <![CDATA[ */
  46.   var imageTags = document.getElementsByTagName('img');
  47.   for(i = 0 ; i < imageTags.length; i++){
  48.     if( imageTags[i].src.indexOf('/s400/', 0)>-1 ) {
  49.       if(imageTags[i].style.width=='400px')
  50.     imageTags[i].style.width='556px';
  51.       else
  52.         imageTags[i].style.width='368px';
  53.       imageTags[i].style.height='';
  54.       imageTags[i].src=imageTags[i].src.replace('/s400/', '/s556/');
  55.     }
  56.   }
  57.   /* ]]> */
  58. </script>