<?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>Takepepe.com &#187; WordPress</title>
	<atom:link href="https://takepepe.com/tag/wordpress/feed/" rel="self" type="application/rss+xml" />
	<link>https://takepepe.com</link>
	<description>Designer::develop</description>
	<lastBuildDate>Sun, 16 Jun 2013 15:40:24 +0000</lastBuildDate>
	<language>ja</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>WordPress #001</title>
		<link>https://takepepe.com/wordpress-001/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=wordpress-001</link>
		<comments>https://takepepe.com/wordpress-001/#comments</comments>
		<pubDate>Fri, 15 Feb 2013 04:00:57 +0000</pubDate>
		<dc:creator>Takepepe</dc:creator>
				<category><![CDATA[Server]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://takepepe.com/?p=147</guid>
		<description><![CDATA[記念すべき第一回目の投稿です。 このブログでは、新しめのことから、ちょっと流行遅れのことまでいろいろ取り上げて [...]]]></description>
				<content:encoded><![CDATA[<p>記念すべき第一回目の投稿です。<br />
  このブログでは、新しめのことから、ちょっと流行遅れのことまでいろいろ取り上げていきたいと思います。少し古くても、アイデア次第ではまだまだ面白くなる技術は多数あります。</p>
<p>Google先生と共に技術を蓄えてきたたわけですが、もちろんGoogle先生だけでなく、偉大な先人たちのおかげで多くのことを学びました。改めて敬意を表するとともに、私と同じように、これから独学でWEBデザイン・メディアアートに挑戦しようとしている皆さんの役にたてればと思い、ブログを立ち上げました。というわけで第一回目の投稿は、当ブログでも利用しているWordPressに関する記事です。</p>
<p>ご存知のとおりWordPressはPHPで構成されたブログシステムで、配布されているテーマやプラグインで自前のブログを短時間で簡単に作れてしまいます。多くのレンタルサーバーではボタン一発でインストールが出来たりと、ハードルは低いです。WordPressのインストール方法や便利なプラグインの紹介は既に良記事がたくさんあるので、そちらを参考にしてください。</p>
<h2>「Takepepe.com」TOPに用いている表現</h2>
<p>このブログでは記事を投稿する際にアイキャッチ画像（以下サムネイル）が選択されていると、ひとつなぎになったグレースケール画像がPHPで生成されるようになっています。わざわざPHPで画像を生成しなくても、CSSやcanvasで実装出来そうですが、今回はこの方法をとっています。具体的な流れは以下の通りです。</p>
<ol>
<li>記事を投稿する際に、サムネイル生成関数を呼ぶ</li>
<li>生成関数で輝度・彩度の調整をして合成</li>
<li>TOP用のWordPressテンプレートを作成</li>
</ol>
<p>ブログを手っ取り早く立ち上げたかったため、デフォルトのテーマを直にいじりました。<br />
  バックアップなどは自己責任でお願いします</p>
<h3>1.記事を投稿する際に、サムネイル生成関数を呼ぶ</h3>
<p>post.php に数行追加します。<br />
  生成関数は2に記述します。</p>
<h5>「wp-admin/post.php」を編集</h5>
<pre class="brush: php; title: ; notranslate">
  
  
// ファイル上部に追加
require_once('./makeTopThum.php');

////// 〜中略〜 //////

// ファイル末に追加
if(has_post_thumbnail($post_id)){ //サムネイルがあった場合
	
	//「makeTopThum.php」に記述されている関数
	makeTopThum(get_the_post_thumbnail($post_id));
	
}

</pre>
<h3>2.生成関数で輝度・彩度の調整をして合成</h3>
<p>PHPで画像にフィルターなどかけながら8枚の画像を1つにまとめます。<br />
  画像パスの取得はもっと良い方法がありそうですが、とりあえず。<br />
  画像生成はそれなりにサーバー負荷がかかりますので、クライアントワーク等に使用する際は気をつけてください。</p>
<h6>Before</h6>
<p>  <img src="/wp-content/uploads/2013/02/WordPress_001.jpg" width="80" /></p>
<h6>After</h6>
<p>  <img src="/wp-content/uploads/2013/02/WordPress_001-top.jpg" width="644" /></p>
<h5>「wp-admin/makeTopThum.php」を新規作成</h5>
<pre class="brush: php; title: ; notranslate">
&lt;?php
function makeTopThum($_img){
	
    $THUM_WIDTH = 160; //サムネイル幅
    $THUM_HEIGHT = 90; //サムネイル高さ
    $NUM = 8; //画像数
	$WIDTH = ($THUM_WIDTH+1)*$NUM; //出力する画像の幅
	$HEIGHT = $THUM_HEIGHT+1; //出力する画像の高さ
	
    
	//出力先の画像を作成
	$dst = imagecreatetruecolor($WIDTH, $HEIGHT);
	
	//白で塗る
	$white = imagecolorallocate($dst, 0xFF, 0xFF, 0xFF);
	imagefill($dst, 0, 0, $white);
	
	//アイキャッチ画像のパス
	preg_match_all(&quot;/&lt;img [^&gt;]*src\s*=\s*[\&quot;']?([^\&quot;'&gt; ]+)/i&quot;, $_img, $mt);
	$srcs = array_map('htmlspecialchars_decode', $mt[1]);
	$src = $srcs[0];
	
	//画像名の取得
	$index = mb_strrpos($src,&quot;/&quot;);
	$name = substr($src, $index+1, -4);
	
	//画像ディレクトリの取得
	$index = mb_strrpos($src,&quot;/&quot;);
	$dir = $_SERVER['DOCUMENT_ROOT'];
	$dir .= substr($src, 19, $index-18);
	
	//新画像のパス
	$new = $dir.$name.&quot;-top.jpg&quot;;
	
	//画像を8つ並べる
	$arr = array(200,150,100,50,0,50,100,150); //輝度配列
	for($i = 0; $i&lt;$NUM ;$i++){
		$thum = imagecreatefromjpeg($src);
		imagefilter($thum, IMG_FILTER_BRIGHTNESS, $arr[$i]); //輝度調整
		imagefilter($thum, IMG_FILTER_GRAYSCALE); //グレースケール変換
		imagecopy($dst, $thum, $i*($THUM_WIDTH+1), 0, 0, 0, $THUM_WIDTH, $THUM_HEIGHT);　//画像配置
		imagedestroy($thum);
	}
	
	//画像保存
	imagejpeg($dst, $new, 100);
	imagedestroy($dst);
	
}

?&gt;
</pre>
<h3>3.TOP用のWordPressテンプレートを作成</h3>
<p>最後にTOP用のテンプレートを作成して、CSSを調整すれば完成です。</p>
<h5>「wp-content/themes/(利用しているテーマ)/content-top.php」を新規作成</h5>
<pre class="brush: php; title: ; notranslate">


&lt;?php

$title = get_the_title(); //タイトル
$date = get_the_date(); //投稿日
$url = get_permalink(); //パーマリンク

//アイキャッチ画像のパス
$img = get_the_post_thumbnail();

//統合画像のパスに変換
preg_match_all(&quot;/&lt;img [^&gt;]*src\s*=\s*[\&quot;']?([^\&quot;'&gt; ]+)/i&quot;, $img, $mt);
$srcs = array_map('htmlspecialchars_decode', $mt[1]);
$src = $srcs[0];
$path = substr($src, 19, -4).&quot;-top.jpg&quot;;

echo &quot;&lt;a href=\&quot;$url\&quot; style=\&quot;background:url($path);\&quot;&gt;&lt;span class=\&quot;title\&quot;&gt;$title&lt;span class=\&quot;date\&quot;&gt;$date&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&quot;;

?&gt;


</pre>
<p>デザイナーの人も、サーバーでPhotoshopみたいに画像を編集出来ることを知っていれば、CMS経由のコンテンツデザインの幅がぐっと広がります。是非、挑戦してみてください。</p>
]]></content:encoded>
			<wfw:commentRss>https://takepepe.com/wordpress-001/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

 Served from: takepepe.com @ 2026-04-12 17:13:58 by W3 Total Cache -->