友圈头像不再兜底第三方默认头像:改用站内/api/favicon(绝对地址),兜底也从cravatar换成自建服务
Deploy to Production / pre-check (push) Successful in 48s
Deploy to Production / build (push) Canceled after 2m55s
Deploy to Production / deploy-edgeone (push) Canceled after 0s
Deploy to Production / finalize (push) Canceled after 0s
Deploy to Production / notify-failure (push) Canceled after 0s
Deploy to Production / pre-check (push) Successful in 48s
Deploy to Production / build (push) Canceled after 2m55s
Deploy to Production / deploy-edgeone (push) Canceled after 0s
Deploy to Production / finalize (push) Canceled after 0s
Deploy to Production / notify-failure (push) Canceled after 0s
This commit is contained in:
1 parent
5858188628
commit
899dcfd006
1 file changed
+14
-2
@@ -333,6 +333,15 @@
|
||||
</div>
|
||||
|
||||
<script>
|
||||
/* 站内 RSS/favicon 服务地址(友圈头像兜底用,替代原先的 cravatar 默认灰头像) */
|
||||
var RSS_API_BASE = '{{ site.Params.rssapi.base | default "https://api.200181.xyz" }}';
|
||||
/* 头像加载失败 → 换站内 favicon 服务;再失败就让它显示接口自带的字母兜底图 */
|
||||
function fcAvatarFallback(img) {
|
||||
img.onerror = null;
|
||||
var target = img.getAttribute('data-fallback') || '';
|
||||
img.src = RSS_API_BASE + '/api/favicon' + (target ? '?url=' + encodeURIComponent(target) : '');
|
||||
}
|
||||
|
||||
window.FriendCircle = {
|
||||
allPosts: [],
|
||||
currentIndex: 0,
|
||||
@@ -374,7 +383,7 @@
|
||||
+ '<img src="' + bgImageSrc + '" class="fc-bg-image" onerror="this.style.opacity=0">'
|
||||
+ '<div class="fc-bottom">'
|
||||
+ '<div class="fc-author-pill">'
|
||||
+ '<img src="' + post.avatar + '" class="fc-avatar" onerror="this.src=\'https://cravatar.cn/avatar/default?s=50\'">'
|
||||
+ '<img src="' + post.avatar + '" class="fc-avatar" data-fallback="' + (post.blogUrl || post.link || '') + '" onerror="fcAvatarFallback(this)">'
|
||||
+ '<span class="fc-author-name">' + post.author + '</span>'
|
||||
+ '</div>'
|
||||
+ '<div class="fc-date"><i class="ri-calendar-line"></i> ' + dateStr + '</div>'
|
||||
@@ -460,7 +469,10 @@
|
||||
link: a.link || '',
|
||||
date: a.pubDate || '',
|
||||
author: a.feedName || a.author || '',
|
||||
avatar: a.favicon || '',
|
||||
// 源里没图标 → 用站内 favicon 服务(返回真实图标或字母 SVG,不是灰头像)
|
||||
avatar: a.favicon || (a.siteUrl || a.link
|
||||
? RSS_API_BASE + '/api/favicon?url=' + encodeURIComponent(a.siteUrl || a.link)
|
||||
: ''),
|
||||
blogUrl: a.siteUrl || '',
|
||||
image: null,
|
||||
description: ''
|
||||
|
||||
Reference in new issue
Block a user