<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>2Drops! &#187; Lightbox</title>
	<atom:link href="http://www.2drops.jp/tag/lightbox/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.2drops.jp</link>
	<description>アナログ好きなデジタル人間の頭の中</description>
	<lastBuildDate>Tue, 29 Mar 2011 09:12:18 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Lightbox 2.04をWoedpressで使う</title>
		<link>http://www.2drops.jp/2009/02/lightbox/</link>
		<comments>http://www.2drops.jp/2009/02/lightbox/#comments</comments>
		<pubDate>Sun, 01 Feb 2009 05:33:17 +0000</pubDate>
		<dc:creator>きさら</dc:creator>
				<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[Lightbox]]></category>

		<guid isPermaLink="false">http://www.2drops.jp/?p=108</guid>
		<description><![CDATA[Lightbox2を導入しました。Wordpressで使うための設定方法です。]]></description>
			<content:encoded><![CDATA[<p>今までHighslide JSを利用していたのですが、タグの記述がかなり面倒でした。<br />
得に複数の画像をグループ化するのが・・・(^^;<br />
ブログを書く環境が完全にLinuxに移行したので、またテキストエディタで下書き生活なんですよね。<br />
簡単に記述できるものはないかと探して、最終的に[Lightbox JS](http://www.lokeshdhakar.com/projects/lightbox2/)で落ち着きました。</p>
<p>使うとこのような感じで画像が表示されます。</p>
<p><a href="http://farm4.static.flickr.com/3126/2923970602_6cbd9a214e.jpg" rel="lightbox" title="Red dragonflies / あかとんぼ"><br />
<img src="http://farm4.static.flickr.com/3126/2923970602_6cbd9a214e_m.jpg" alt="Red dragonflies / あかとんぼ" id="image" /><br />
</a></p>
<p>完全にいまさらな、という状態ですが、導入手順と使い方をメモしておきます。</p>
<p><span id="more-108"></span></p>
<p>### 手順1：ダウンロード</p>
<p>[Lightbox 2](http://www.lokeshdhakar.com/projects/lightbox2/)からダウンロードします。</p>
<p>わずか2クリックでダウンロード完了なので、英語が苦手でも問題無です。<br />
zip形式なので、最近のPCなら解凍ソフトを入れなくても開けますね。</p>
<p>### 手順2：スクリプトの修正</p>
<p>以下の2つのファイルを修正します。<br />
絶対パスで指定するので、ブログのようなテンプレートで全ページを生成する場合でも、きちんとファイルの場所を参照できます。</p>
<p>#### js/lightbox.js</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>48
49
50
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">LightboxOptions <span style="color: #339933;">=</span> Object.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
   fileLoadingImage<span style="color: #339933;">:</span>              <span style="color: #3366CC;">'images/loading.gif'</span><span style="color: #339933;">,</span>     
   fileBottomNavCloseImage<span style="color: #339933;">:</span>  <span style="color: #3366CC;">'images/closelabel.gif'</span><span style="color: #339933;">,</span></pre></td></tr></table></div>

<p>上記の部分を、下記のように修正</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>48
49
50
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">LightboxOptions <span style="color: #339933;">=</span> Object.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
   fileLoadingImage<span style="color: #339933;">:</span>             <span style="color: #3366CC;">'＜サイトURL＞/images/loading.gif'</span><span style="color: #339933;">,</span>     
  fileBottomNavCloseImage<span style="color: #339933;">:</span> <span style="color: #3366CC;">'＜サイトURL＞/images/closelabel.gif'</span><span style="color: #339933;">,</span></pre></td></tr></table></div>

<p>#### css/lightbox.css</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#prevLink</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#prevLink</span><span style="color: #3333ff;">:visited</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../images/prevlabel.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #933;">15%</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nextLink</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#nextLink</span><span style="color: #3333ff;">:visited</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../images/nextlabel.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #933;">15%</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>上記の部分を、下記のように修正</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>16
17
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#prevLink</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#prevLink</span><span style="color: #3333ff;">:visited</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>＜サイトURL＞/images/prevlabel.gif<span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">left</span> <span style="color: #933;">15%</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#nextLink</span><span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#nextLink</span><span style="color: #3333ff;">:visited</span><span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span>＜サイトURL＞/images/nextlabel.gif<span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #933;">15%</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>### 手順3：アップロード</p>
<p>3つのフォルダ(css/js/images)をサイトのトップか、Wordpressの設定で「ブログのアドレス (URL)」に設定したところに配置します。<br />
このブログだと http://www.2drops.jp/ 直下になります。</p>
<p>### 手順4：テーマの修正</p>
<p>header.phpの最後のほう**`<?php endif; ?>`から`<?php wp_head(); ?>`**までに以下を追記します。</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;script type=&quot;text/javascript&quot; src=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/highslide/highslide.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
    hs.graphicsDir = '<span style="color: #000000; font-weight: bold;">&lt;?php</span> bloginfo<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'home'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>/highslide/graphics/';
&lt;/script&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> wp_head<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>### 手順5：記事を書く</p>
<p>Lightboxを適用したいリンクを、以下のように記述します。<br />
テキストならこのような感じ</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像のファイル名&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lightbox&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;開いた時に表示される説明&quot;</span>&gt;</span>リンクの文字<span style="color: #009900;">&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p>画像ならこのような感じ</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像のファイル名&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lightbox&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;開いた時に表示される説明&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;サムネイルのファイル名&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像名&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

<p>複数の画像をグループ化することもできます。<br />
その場合は*[group_name]を半角英数で*記述します。同じ[group_name]がセットとなり、スライドショーで表示されます。</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像1のファイル名&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lightbox[group_name]&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;開いた時に表示される説明&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;サムネイル1のファイル名&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像名&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">a</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像2のファイル名&quot;</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;lightbox[group_name]&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;開いた時に表示される説明&quot;</span>&gt;&lt;<span style="color: #000000; font-weight: bold;">img</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;サムネイル2のファイル名&quot;</span> <span style="color: #000066;">alt</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;画像名&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">a</span>&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.2drops.jp/2009/02/lightbox/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

