1

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 に変更 ます860/偽

サイトでjqueryで作成したのを見たと思いますが、名前を覚えていません。履歴を調べると見つかるかもしれません。

助けてくれてありがとう。

Edit.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に合わせて拡大縮小されません.

4

2 に答える 2

1

これは結構出てきそうですね。Tumblr フォトセットを完全にレスポンシブにする jQuery プラグインを開発し、コンテナーを設定した任意の幅に拡張できます。https://github.com/PixelUnion/Extended-Tumblr-Photoset

より多くの情報(EXIFデータを含む)を取得し、コンテンツを完全に制御できるため、iFrameサイズをいじるよりもこれを好みます.

于 2012-11-01T23:19:38.250 に答える
0

私は自分の問題の解決策を見つけました。ここにあります:

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

スクリプトを最小化または改善する方法についてのアイデアがあれば、以下に投稿してください。楽しみ

于 2012-10-31T14:20:12.763 に答える