함수를 아래와 같이 설정했습니다.
function oz_thumbnail($width, $height) {
global $post;
$content = $post->post_content; // $soImages = ‘~<img [^>]* />~’;
preg_match_all(‘/<img.*?(?: |\t|\r|\n)?src=[‘”]?(.+?)[‘”]?(?:(?: |\t|\r|\n)+.*?)?>/sim’, $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
$m = substr_count($strResult[1][0], ‘timthumb.php’);
if ($n > 0) {
if ($m == 1) {
echo ‘<div class=”entry-thumb”><img class=”alignleft” src=”‘.preg_replace(“/&h.*zc=1/”,””,$strResult[1][0]).’&h=’.$height.’&w=’.$width.’&zc=1″ alt=”” /></div>’;
} else {
echo ‘<div class=”entry-thumb”><img class=”alignleft” src=”‘.get_bloginfo(‘template_url’).’/timthumb.php?src=’.$strResult[1][0].’&h=’.$height.’&w=’.$width.’&zc=1″ alt=”” /></div>’;
}
}
}
그리고 카테고리 페이지에서 글 리스트의 썸네일을 <?php oz_thumbnail(100,100); ?> 이런 방식으로 출력했습니다.
위와 같이 할 경우 썸네일 사이즈를 가로 세로 정확하게 설정하여 출력되는데요,
가로 사이즈가 세로 사이즈보다 클 경우 가로 사이즈 기준, 세로 사이즈가 가로 사이즈보다 클 경우 세로 사이즈 기준으로 출력하려면 어떻게 해야 하나요?
혹시 아시는 분 계시면 답변 좀 부탁드립니다.