「Ktai Style」でPicasa画像をインライン表示する方法 【WordPress】

  • 投稿 : 2013-06-16
Wordpressのプラグインの「Ktai Style」は携帯(ガラケー)対応してくれてありがたいプラグインなんですが、Picasa画像をインライン表示してくれないんですね。Flickr画像は対応していて、インライン表示してくれます。

そこで、Picasa画像をインライン表示できるようにしてみました。wp-content/plugins/ktai-style/inc/にある「shrinkage.php」を修正します。

■修正前
$this->image_services = apply_filters('ktai_image_services', array(
		'^https?://[-\w.]+\.flickr.com/' => array($this, 'get_thumbnail_flickr'),
	));

■修正後
$this->image_services = apply_filters('ktai_image_servicess', array(
		'^https?://[-\w.]+\.flickr.com/' => array($this, 'get_thumbnail_flickr'),
		'^https?://[-\w.]+\.blogspot.com/' => array($this, 'get_thumbnail_picasa'),
));

blogspot.comはBloggerでPicasa画像を貼り付けた時のURLなのでほかの場合は違う可能性があります。この辺りは各自の環境に合わせてください。おそらく「ggpht.com」あたりじゃないかなと思います。

あと以下の関数を追加
public function get_thumbnail_picasa($img_src, $img_href = '') {
	if ($img_href) {
	$thumb_url = preg_replace('/\/(w|s|h)(\d+)\//', '/s100/', $img_src);
	} else {
	$thumb_url = preg_replace('/\/(w|s|h)(\d+)\//', '/s100/', $img_src);
	}
	return $thumb_url;
}

「s100」の部分が横幅のサイズになります。この場合は横幅が100pxになります。
Picasa画像のURLの中に、[S数字]になっている部分がありますが、この数字を書き換えると好きなサイズのサムネイルが取得できます。
スポンサーリンク