箱ドット アニメGIFでまわるダパンダ

dapanda hako dot

anime gif

とうとうツイッターのアイコンかわったのだった

@twodolls

いままで使っていた3D版

■ややこしい部分だけメモ
★テンプレート(ループ内)
[php]
画像あったとき
<?php if(catch_that_image()!='/js/lazierload/spinner.gif'): ?>
<?php list($width, $height, $type, $attr) = getimagesize(catch_that_image());
if($width>$height){
$tyhi="width=\"300\"";
}else{
$tyhi="height=\"250\"";
}
?>
代替画像のとき
<?php else: $tyhi="width=\"32\"";
endif; ?>

<img src="<?php echo catch_that_image(); ?>" title="<?php the_title('', 'を見る'); ?>" onclick="window.open('<?php the_permalink(); ?>','_parent')" <?php echo $tyhi; ?> style="cursor: pointer;" />
[/php]

★テーマのための関数
[php]
// ===== 記事中の最初の画像を自動検出して、表示 ===== //

function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('<img.+src=[\'"]([^\'"]+)[\'"].*'.'/>', $post->post_content, $matches);
$first_img = $matches [1] [0];

if(empty($first_img)){ //画像がないときの替わりの画像
$first_img = "/js/lazierload/spinner.gif";
}
return $first_img;
}
[/php]
(やりたかったあの機能を実現する、WordPress 中級者必見のカスタマイズ6個)

前へ

ラフ 男エルフ

次へ

完成 男エルフ