-
post_content;
$searchPattern = ‘//i’;//投稿にimgタグが含まれているか調べる
if (has_post_thumbnail())
{/**サムネイルを設定している場合はそのURLを取得。**/
$image_id = get_post_thumbnail_id();
$image = wp_get_attachment_image_src( $image_id, ‘thumbnail’);
$infoimage=$image[0];
}
else if ( preg_match( $searchPattern, $str, $imgurl ))
{/**サムネイルを設定していない場合は、投稿の最初の画像を
サムネイルのサイズに縮小したもののURLを取得。**/
$infoimage=$imgurl[2];
$infoimage=preg_replace(“/-[0-9]+x[0-9]+/”,””,$infoimage);
$infoimage=str_replace(“.jpg”, “-162×107.jpg”, $infoimage);
$infoimage=str_replace(“.png”, “-162×107.png”, $infoimage);
$infoimage=str_replace(“.gif”, “-162×107.gif”, $infoimage);
}
else
{/**投稿にサムネイルを設定しておらず、
投稿内に画像が一枚も無い場合は、
テーマファイルのディレクトリーにアップロードした
no_image.pngの絶対パスを取得。**/
/**$infoimage=get_stylesheet_directory_uri().”/no_image.png”;**/
$infoimage= catch_that_image();
}
?>
” width=”99″ alt=”” class=”imgR” />‘shop’,’posts_per_page’ => 100,’orderby’ => ‘date’,’order’ => ‘ASC’,’page_id’ => 147); ?>
have_posts() ) : $loop->the_post(); ?>