feat: optimize thumbnail image ratio (#302 #303)

pull/321/head^2
Seaton Jiang 2020-12-14 11:37:02 +08:00
parent 1934710b9b
commit e270b99533
No known key found for this signature in database
GPG Key ID: C1086BAE716FF138
2 changed files with 6 additions and 3 deletions

View File

@ -573,8 +573,8 @@ button:focus {
float: left; float: left;
overflow: hidden; overflow: hidden;
margin: 20px; margin: 20px;
width: 240px; width: 256px;
height: 145px; height: 144px;
} }
.k-main .board .article-panel .a-thumb img { .k-main .board .article-panel .a-thumb img {

View File

@ -101,12 +101,15 @@ add_filter('excerpt_length', 'excerpt_length');
// 开启特色图 // 开启特色图
add_theme_support("post-thumbnails"); add_theme_support("post-thumbnails");
// 生成适合特色图的比例图片
add_image_size( 'kratos-thumbnail', 512, 288, true );
// 文章特色图片 // 文章特色图片
function post_thumbnail() function post_thumbnail()
{ {
global $post; global $post;
$img_id = get_post_thumbnail_id(); $img_id = get_post_thumbnail_id();
$img_url = wp_get_attachment_image_src($img_id, array(720, 435)); $img_url = wp_get_attachment_image_src($img_id, 'kratos-thumbnail');
if (is_array($img_url)) { if (is_array($img_url)) {
$img_url = $img_url[0]; $img_url = $img_url[0];
} }