2012-07-17 80 views
1

我知道tumblr的圖片尺寸有{photoset-500},{photoset-400},{photoset-250},但我想更改寬度,以便寬度可以是420或350.我到處尋找,找不到代碼來幫助我做到這一點。在tumblr上更改默認圖片尺寸

回答

1

您不能使用Tumblr標記更改圖像的默認尺寸,但您可以使用CSS在視覺上更改尺寸。

的tumblr標記:

{block:Photoset} 
    {block:Photos} 
     <img src="{PhotoURL-500}" class="photoset-img" /> 
    {/block:Photos} 
{/block:Photoset} 

CSS:

.photoset-img { width: 420px; /* can be any value you want */ } 
+0

不要忘了調整高度。 '.photoset-img {width:420px;身高:自動; }' – graygilmore 2012-07-20 23:33:03

+1

'auto'是默認值 – 2012-07-21 02:34:19

1

結束標記之前添加此腳本。這將增加或減少photoset的大小

<script type="text/javascript"> 
    //This will change the source address and display the correct size. 
       $(".photoset").each(function() { 
      var newSrc = $(this).attr("src").replace('700','860'); 
      $(this).attr("src", newSrc);  
     }); 
    //This will get the new size of the iframe and resize the iframe holder accordingly. 
     $(function(){ 
     var iFrames = $('.photoset'); 
     function iResize() { 
      for (var i = 0, j = iFrames.length; i < j; i++) { 
       iFrames[i].style.height = iFrames[i].contentWindow.document.body.offsetHeight + 'px';} 
      } 

      if ($.browser.safari || $.browser.opera) { 
       iFrames.load(function(){ 
        setTimeout(iResize, 0); 
       }); 

       for (var i = 0, j = iFrames.length; i < j; i++) { 
        var iSource = iFrames[i].src; 
        iFrames[i].src = ''; 
        iFrames[i].src = iSource; 
       } 
      } else { 
       iFrames.load(function() { 
        this.style.height = this.contentWindow.document.body.offsetHeight + 'px'; 
       }); 
      } 
     }); 
</script>