【问题标题】:Tumblr PhotosetTumblr 照片集
【发布时间】:2012-10-20 13:48:18
【问题描述】:

我正在尝试破解 tumblr 照片集,我想我找到了最大 700 显示尺寸的修复程序。

假设这是由 {Photoset-700} 生成的普通 iframe:

<iframe class="photoset" scrolling="no" frameborder="0" height="1048" width="700" style="border:0px; background-color:transparent; overflow:hidden;" src="http://www.georgefratila.ro/post/20314734048/photoset_iframe/esssk/tumblr_m1tp5634Si1qzc7t7/700/false"></iframe>

有没有办法改变iframe的宽度,改变src url的最后一部分和放大时保持纵横比?

width="700" 将此值更改为 860 src="http://www.georgefratila.ro/post/20314734048/photoset_iframe/esssk/tumblr_m1tp5634Si1qzc7t7/700/false" 将src的最后一部分/700/false改成/860/false

我想我在一个网站上看到它是用 jquery 制作的,但我不记得名字了,我会查看我的历史也许我会找到它。

感谢您的帮助。

编辑.1 我想我几乎对所有东西都进行了排序:

        $('iframe.photoset').each(function() {
      $(this).attr("width", function(index, old) {
            return old.replace("700", "860");
      });
      $(this).attr("src", function(index, old) {
            return old.replace("/700/false", "/860/false");
      });
});

我现在唯一的问题是高度,它无法缩放以适应 iframe。

【问题讨论】:

    标签: jquery tumblr


    【解决方案1】:

    这似乎出现了很多。我开发了一个 jQuery 插件,它可以让 Tumblr Photosets 完全响应,并且可以达到你设置容器的任何宽度。 https://github.com/PixelUnion/Extended-Tumblr-Photoset

    我更喜欢这个而不是摆弄 iFrame 大小,因为您可以获得更多信息(包括 EXIF 数据),并且真正让您完全控制内容。

    【讨论】:

      【解决方案2】:

      我找到了解决问题的方法,这里是:

      //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';
              });
          }
      });
      

      如果您对如何最小化或改进脚本有任何想法,请在下方发布。享受

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-09-24
        • 2021-10-20
        相关资源
        最近更新 更多