
>
Wordpress > wordpress カスタムフィールドテンプレートで画像サイズを指定して表示
wordpress カスタムフィールドテンプレートで画像サイズを指定して表示 2013年2月20日
Tag:
wordprss カスタムフィールドテンプレートで画像サイズを指定して表示する方法です。
<?php
$img[0]=get_post_meta($post->ID,'メイン画像1',true);
?>
<?php $imgUrl_0=wp_get_attachment_image_src($img[0],'full');?>
<a href="<?php echo $imgUrl_0[0];?>" rel="lightbox" alt="" title=""/>
<?php
$attach_id = get_post_meta($post->ID,"メイン画像1",true);
$image_info = wp_get_attachment_image_src( $attach_id , 'full' );
list( $url, $w, $h) = $image_info;
$h = intval(200 * ( $h / $w ));
$alt = get_post_meta($attach_id , '_wp_attachment_image_alt', true);
?>
<img class="zzzz" src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" width="200px" height="<?php echo $h; ?>" />
</a>