MacのVSCode(VisualStudioCode)のClineでOllamaが動作しない時の解決備忘録
2024.11.13
WordPressでメディアのサムネイルを一括で再生成するプラグイン『Regenerate Thumbnails』
2023.09.23
MacでOpen Interpreterをローカルで動かした際に、CodeLlama Modelがダウンロードされる場所
2023.09.09
Category WordPress Tips Update 2010.10.14
WordPressでトップページにサムネイルなどで投稿の画像を並べる場合
カスタムフィールドで画像を登録することもできるのですが、
下記の用に投稿から抜き出すようにfunction.phpに記述しておけば
自動的に引っ張ってこれる
function.phpに記述
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches [1] [0];
if(empty($first_img)){ //Defines a default image
$first_img = "http://img149.imageshack.us/img149/8779/curses.png";
}
return $first_img;
}
home.phpなどでの記述方法
<img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>" /></a>