Created
March 27, 2012 15:51
-
-
Save mattintosh4/2217349 to your computer and use it in GitHub Desktop.
Picasaウェブアルバムの写真をjQueryのColorBoxプラグインで開きます。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function(){ | |
var img = $('.articles-body a[href^="https://picasaweb.google.com"]:has("img[src*="googleusercontent.com"]")'); | |
for(i=0,l=img.length;i<l;i++){ | |
var a = $(img).eq(i).children('img').attr('src').split('/'); | |
var regExp = /^[cdhpsw](\d+)?(-[cp])?(-r\d+)?$/; // 2012年03月までに確認出来ているサムネイルのパラメータに対応します | |
if(regExp.test(a[7])==1){ | |
a.splice(7,1,"s960"); //"s960"を変更することで最大サイズの指定が可能です | |
var u = a.join("/"); | |
$(img).eq(i) | |
.attr({ | |
title:$(img).eq(i).attr('href'), | |
href:u, | |
rel:'lightbox' | |
}) | |
.colorbox({ // ColorBoxプラグイン独自の設定です | |
transition:'fade', | |
maxWidth:'95%', // ウィンドウ幅95%を最大とします | |
maxHeight:'95%', // ウィンドウ高さ95%を最大とします | |
title:function(){ | |
var url = $(this).attr('title'); | |
return '<a href="'+url+'" target="_blank">full size</a>' // Picasaウェブアルバムへのリンクに好きなアンカーテキストを指定出来ます | |
} | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment