v1.1 — 图片/头像/作者/日期全面优化
- 图片: 缩略图改为 soft crop,原图裁黑边 - 头像: 团队证件照替换 SVG,CSS 约束尺寸和圆角 - 作者: 了心/墨羽/探子三个真实用户 - 笺文列表: 左侧增加封面缩略图 - 分页: 20篇/页 - 详情页: 返回笺文链接 + 头像尺寸约束 - 作者页: 高清头像 + 中文日期 - 微言: 作者随机 + 时间匹配内容
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ $author_query = new WP_Query(array(
|
|||||||
<a href="<?php the_permalink(); ?>" class="article-item">
|
<a href="<?php the_permalink(); ?>" class="article-item">
|
||||||
<span class="article-title"><?php the_title(); ?></span>
|
<span class="article-title"><?php the_title(); ?></span>
|
||||||
<span class="article-meta">
|
<span class="article-meta">
|
||||||
<span><?php echo get_the_date(); ?></span>
|
<span><?php echo get_the_date('Y-m-d'); ?></span>
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
<?php endwhile; ?>
|
<?php endwhile; ?>
|
||||||
|
|||||||
+12
-4
@@ -141,11 +141,19 @@ add_action('template_include', function($template) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 禁用 Gravatar — 本地默认头像
|
// 本地头像(团队证件照)
|
||||||
add_filter('get_avatar', function($avatar, $id_or_email, $size, $default, $alt) {
|
add_filter('get_avatar', function($avatar, $id_or_email, $size, $default, $alt) {
|
||||||
// 用 data URI 的默认灰色圆圈替代
|
$uid = 0;
|
||||||
$svg = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 40 40" width="' . $size . '" height="' . $size . '"><circle cx="20" cy="20" r="20" fill="#e0d6c5"/><circle cx="20" cy="15" r="7" fill="#c4826e"/><ellipse cx="20" cy="32" rx="13" ry="9" fill="#c4826e"/></svg>';
|
if (is_numeric($id_or_email)) $uid = (int) $id_or_email;
|
||||||
return '<span class="avatar-local" style="display:inline-flex;align-items:center;vertical-align:middle;width:' . $size . 'px;height:' . $size . 'px;border-radius:50%;overflow:hidden;">' . $svg . '</span>';
|
elseif (is_object($id_or_email) && isset($id_or_email->user_id)) $uid = (int) $id_or_email->user_id;
|
||||||
|
$att_id = get_user_meta($uid, 'custom_avatar', true);
|
||||||
|
if ($att_id) {
|
||||||
|
$url = wp_get_attachment_image_url($att_id, 'medium');
|
||||||
|
if ($url) {
|
||||||
|
return '<img src="' . esc_url($url) . '" class="avatar avatar-' . $size . ' photo" width="' . $size . '" height="' . $size . '" alt="" />';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $avatar; // fallback
|
||||||
}, 10, 5);
|
}, 10, 5);
|
||||||
|
|
||||||
// 激活主题时自动初始化
|
// 激活主题时自动初始化
|
||||||
|
|||||||
+6
-1
@@ -5,7 +5,7 @@
|
|||||||
get_header();
|
get_header();
|
||||||
|
|
||||||
$pg = isset($_GET['pg']) ? max(1, (int) $_GET['pg']) : 1;
|
$pg = isset($_GET['pg']) ? max(1, (int) $_GET['pg']) : 1;
|
||||||
$per_page = 3;
|
$per_page = 20;
|
||||||
$query = new WP_Query(array(
|
$query = new WP_Query(array(
|
||||||
'post_type' => 'post',
|
'post_type' => 'post',
|
||||||
'posts_per_page' => $per_page,
|
'posts_per_page' => $per_page,
|
||||||
@@ -23,6 +23,11 @@ $total_pages = ceil($total / $per_page);
|
|||||||
<div class="article-list">
|
<div class="article-list">
|
||||||
<?php while ($query->have_posts()) : $query->the_post(); ?>
|
<?php while ($query->have_posts()) : $query->the_post(); ?>
|
||||||
<a href="<?php the_permalink(); ?>" class="article-item">
|
<a href="<?php the_permalink(); ?>" class="article-item">
|
||||||
|
<?php if (has_post_thumbnail()) : ?>
|
||||||
|
<div class="article-item__thumb">
|
||||||
|
<?php the_post_thumbnail('thumbnail', array('alt' => get_the_title())); ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
<div class="article-item__main">
|
<div class="article-item__main">
|
||||||
<span class="article-title"><?php the_title(); ?></span>
|
<span class="article-title"><?php the_title(); ?></span>
|
||||||
<span class="article-item__author"><?php echo get_avatar(get_the_author_meta('ID'), 14, '', '', array('class' => 'article-avatar')); ?> <?php the_author_meta('display_name'); ?></span>
|
<span class="article-item__author"><?php echo get_avatar(get_the_author_meta('ID'), 14, '', '', array('class' => 'article-avatar')); ?> <?php the_author_meta('display_name'); ?></span>
|
||||||
|
|||||||
@@ -301,3 +301,67 @@ echo "done"
|
|||||||
.article-cover { overflow: hidden; height: 240px; }
|
.article-cover { overflow: hidden; height: 240px; }
|
||||||
|
|
||||||
/* Thumbnail fix — regenerate without black bars */
|
/* Thumbnail fix — regenerate without black bars */
|
||||||
|
|
||||||
|
.article-item__thumb {
|
||||||
|
width: 60px;
|
||||||
|
height: 60px;
|
||||||
|
border-radius: var(--radius);
|
||||||
|
overflow: hidden;
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-right: 16px;
|
||||||
|
}
|
||||||
|
.article-item__thumb img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
.article-item {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar, .pinned-avatar, .card-avatar, .tucao-avatar, .article-avatar, .avatar-sm {
|
||||||
|
object-fit: cover !important;
|
||||||
|
border-radius: 50% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar, .pinned-avatar, .card-avatar, .tucao-avatar, .article-avatar, .avatar-sm {
|
||||||
|
object-position: center 20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.avatar-16, .card-avatar, .tucao-avatar, .article-avatar {
|
||||||
|
width: 16px !important;
|
||||||
|
height: 16px !important;
|
||||||
|
}
|
||||||
|
.avatar-18, .pinned-avatar {
|
||||||
|
width: 18px !important;
|
||||||
|
height: 18px !important;
|
||||||
|
}
|
||||||
|
.avatar-14, .article-avatar {
|
||||||
|
width: 14px !important;
|
||||||
|
height: 14px !important;
|
||||||
|
}
|
||||||
|
.avatar-sm {
|
||||||
|
width: 16px !important;
|
||||||
|
height: 16px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.single-post__meta img,
|
||||||
|
.article-byline img {
|
||||||
|
width: 22px !important;
|
||||||
|
height: 22px !important;
|
||||||
|
border-radius: 50% !important;
|
||||||
|
object-fit: cover !important;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
.article-byline span {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 6px;
|
||||||
|
}
|
||||||
|
.author-card__avatar {
|
||||||
|
width: 56px !important;
|
||||||
|
height: 56px !important;
|
||||||
|
border-radius: 50% !important;
|
||||||
|
object-fit: cover !important;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user