fix(frontend): align post thumbnail display with reference

This commit is contained in:
kate522 committed 2026-10-29 23:07:08 +08:00
1 parent 542daca457
commit 4cdde50695
11 files changed
+201 -104

No files matched your search

-23
View File
@@ -104,21 +104,6 @@
margin: 0 !important;
}
.item-thumbnail .dplayer.dplayer-thumb {
position: absolute;
inset: 0;
z-index: 1;
padding-bottom: var(--posts-list-scale, 70%);
background: #000;
opacity: 0;
transition: opacity 0.3s;
}
.card .item-thumbnail .dplayer.dplayer-thumb {
padding-bottom: var(--posts-card-scale, 70%);
}
.item-thumbnail .dplayer-thumb video,
.item-thumbnail .swiper-wrapper,
.item-thumbnail img {
position: absolute;
@@ -136,14 +121,6 @@
text-align: center !important;
}
.posts-item.thumb-dplayer-playing .dplayer-thumb {
opacity: 1;
}
.posts-item.thumb-dplayer-playing .abs-center {
opacity: 0;
}
.posts-item .item-heading {
display: -webkit-box;
max-height: 2.8em;
+1 -1
View File
@@ -1 +1 @@
.posts-row{margin-right:-8px;margin-bottom:15px;margin-left:-8px}.posts-row>*:not(.post_ajax_loader){margin-right:8px!important;margin-left:8px!important}.posts-row>.post_ajax_loader .posts-item,.posts-row>.post_ajax_loader .posts-mini{margin-right:8px;margin-left:8px}.posts-item{margin:15px 0;padding:20px;overflow:hidden;background:var(--main-bg-color, #fff);border-radius:var(--main-radius, 8px);box-shadow:0 0 10px var(--main-shadow, rgba(116, 116, 116, .08));transition:.2s}.posts-item.flex,.posts-item .flex,.posts-mini .flex{display:flex}.posts-item .flex.xx,.posts-mini .flex.xx{flex-direction:column}.posts-item .flex.ac,.posts-mini .flex.ac{align-items:center}.posts-item .flex.jsb,.posts-mini .flex.jsb{justify-content:space-between}.posts-item .flex1,.posts-mini .flex1{flex:1;overflow:hidden}.posts-item .post-graphic:not(.order1){margin-right:20px}.posts-item .order1.post-graphic{margin-right:0;margin-left:20px}.posts-item .item-thumbnail{position:relative;display:block;width:190px;height:0;padding-bottom:var(--posts-list-scale, 70%);overflow:hidden;border-radius:var(--main-radius, 8px)}.item-thumbnail.contain img{object-fit:contain}.swiper-slide.gradient-bg .dplayer-poster img,.swiper-slide.gradient-bg>*>img{object-fit:contain!important;border-radius:0!important}.item-thumbnail .swiper-wrapper{height:100%!important}.list .item-thumbnail .aksrt-slider,.list .item-thumbnail.new-swiper{position:absolute;width:100%;height:100%;margin:0!important}.item-thumbnail .dplayer.dplayer-thumb{position:absolute;inset:0;z-index:1;padding-bottom:var(--posts-list-scale, 70%);background:#000;opacity:0;transition:opacity .3s}.card .item-thumbnail .dplayer.dplayer-thumb{padding-bottom:var(--posts-card-scale, 70%)}.item-thumbnail .dplayer-thumb video,.item-thumbnail .swiper-wrapper,.item-thumbnail img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.item-thumbnail .swiper-pagination{right:0!important;bottom:0!important;left:0!important;padding:0 2px!important;text-align:center!important}.posts-item.thumb-dplayer-playing .dplayer-thumb{opacity:1}.posts-item.thumb-dplayer-playing .abs-center{opacity:0}.posts-item .item-heading{display:-webkit-box;max-height:2.8em;margin-top:0;margin-bottom:5px;overflow:hidden;font-size:18px;line-height:1.4em;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:2}.font-bold{font-weight:700}.list.style2 .item-thumbnail{width:130px}.list.style2 .item-heading{display:unset;max-height:1.4em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.posts-item .item-heading>a{color:var(--key-color, #333)}.posts-item .item-heading>a:hover{color:var(--focus-color, #f04494)}.posts-item .item-excerpt{margin:0 0 6px;overflow:hidden;color:var(--muted-color, #777);text-overflow:ellipsis;white-space:nowrap}.posts-item .item-meta item{margin-right:8px;font-size:13px}.posts-item .item-meta svg.icon,.posts-mini .item-meta svg.icon{display:inline-block;width:1em;height:1em;margin-right:2px;fill:currentColor;overflow:hidden;vertical-align:-.15em}.posts-item .meta-right item:last-child{margin-right:0}.item-meta .avatar-mini{width:20px;height:20px;border-radius:50%;transform:translateY(-1px)}.item-meta .meta-pay{padding:0 4px}.posts-item .item-meta a,.posts-mini .item-meta a{color:inherit}.posts-item .item-tags a{margin-right:5px;padding:2px 5px;font-size:11px}.posts-item .item-tags a .fa{font-size:1em}.posts-item.card{display:inline-block;width:calc(33.333% - 16px);margin:8px;padding:10px;vertical-align:top;transition:.3s}.posts-item.card:last-child{margin-bottom:20px}.posts-item.card .item-body{width:100%;margin:10px 0 0;padding:0}.posts-item.card .item-meta item{font-size:12px}.posts-mini-con .item-heading,.posts-item.card .item-heading{font-size:14px}.posts-item.card .item-heading{min-height:2.8em}.posts-item.card .item-tags{min-height:23px}.posts-item.card .item-thumbnail{width:100%;padding-bottom:var(--posts-card-scale, 70%)}.posts-item.card.style2{background:transparent;box-shadow:none}.posts-item.card.style2:hover{background:var(--main-bg-color, #fff);box-shadow:0 0 10px var(--main-shadow, rgba(116, 116, 116, .08))}.posts-item.card.style3{padding:0}.posts-item.card.style3 .item-thumbnail,.posts-item.card.style3 .item-thumbnail img{border-radius:var(--main-radius, 8px) var(--main-radius, 8px) 0 0}.posts-item.card.style3 .item-body{margin:0;padding:10px}.posts-item.mult-thumb .thumb-items{margin:0 -3px 6px}.posts-item.mult-thumb .thumb-items>span{position:relative;display:inline-block;width:calc(25% - 6px);height:0;margin:0 3px;padding-bottom:calc(var(--posts-list-scale, 70%) / 4)}.posts-item.mult-thumb .thumb-items>span>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.posts-item.mult-thumb .thumb-items.contain>span{overflow:hidden;background:var(--main-border-color, rgba(50, 50, 50, .06));border-radius:var(--main-radius, 8px)}.posts-item.mult-thumb .thumb-items.contain>span>img{object-fit:contain;border-radius:0}.posts-item.no_margin{margin:0;border-radLine truncated
.posts-row{margin-right:-8px;margin-bottom:15px;margin-left:-8px}.posts-row>*:not(.post_ajax_loader){margin-right:8px!important;margin-left:8px!important}.posts-row>.post_ajax_loader .posts-item,.posts-row>.post_ajax_loader .posts-mini{margin-right:8px;margin-left:8px}.posts-item{margin:15px 0;padding:20px;overflow:hidden;background:var(--main-bg-color, #fff);border-radius:var(--main-radius, 8px);box-shadow:0 0 10px var(--main-shadow, rgba(116, 116, 116, .08));transition:.2s}.posts-item.flex,.posts-item .flex,.posts-mini .flex{display:flex}.posts-item .flex.xx,.posts-mini .flex.xx{flex-direction:column}.posts-item .flex.ac,.posts-mini .flex.ac{align-items:center}.posts-item .flex.jsb,.posts-mini .flex.jsb{justify-content:space-between}.posts-item .flex1,.posts-mini .flex1{flex:1;overflow:hidden}.posts-item .post-graphic:not(.order1){margin-right:20px}.posts-item .order1.post-graphic{margin-right:0;margin-left:20px}.posts-item .item-thumbnail{position:relative;display:block;width:190px;height:0;padding-bottom:var(--posts-list-scale, 70%);overflow:hidden;border-radius:var(--main-radius, 8px)}.item-thumbnail.contain img{object-fit:contain}.swiper-slide.gradient-bg .dplayer-poster img,.swiper-slide.gradient-bg>*>img{object-fit:contain!important;border-radius:0!important}.item-thumbnail .swiper-wrapper{height:100%!important}.list .item-thumbnail .aksrt-slider,.list .item-thumbnail.new-swiper{position:absolute;width:100%;height:100%;margin:0!important}.item-thumbnail .swiper-wrapper,.item-thumbnail img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.item-thumbnail .swiper-pagination{right:0!important;bottom:0!important;left:0!important;padding:0 2px!important;text-align:center!important}.posts-item .item-heading{display:-webkit-box;max-height:2.8em;margin-top:0;margin-bottom:5px;overflow:hidden;font-size:18px;line-height:1.4em;white-space:normal;-webkit-box-orient:vertical;-webkit-line-clamp:2}.font-bold{font-weight:700}.list.style2 .item-thumbnail{width:130px}.list.style2 .item-heading{display:unset;max-height:1.4em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.posts-item .item-heading>a{color:var(--key-color, #333)}.posts-item .item-heading>a:hover{color:var(--focus-color, #f04494)}.posts-item .item-excerpt{margin:0 0 6px;overflow:hidden;color:var(--muted-color, #777);text-overflow:ellipsis;white-space:nowrap}.posts-item .item-meta item{margin-right:8px;font-size:13px}.posts-item .item-meta svg.icon,.posts-mini .item-meta svg.icon{display:inline-block;width:1em;height:1em;margin-right:2px;fill:currentColor;overflow:hidden;vertical-align:-.15em}.posts-item .meta-right item:last-child{margin-right:0}.item-meta .avatar-mini{width:20px;height:20px;border-radius:50%;transform:translateY(-1px)}.item-meta .meta-pay{padding:0 4px}.posts-item .item-meta a,.posts-mini .item-meta a{color:inherit}.posts-item .item-tags a{margin-right:5px;padding:2px 5px;font-size:11px}.posts-item .item-tags a .fa{font-size:1em}.posts-item.card{display:inline-block;width:calc(33.333% - 16px);margin:8px;padding:10px;vertical-align:top;transition:.3s}.posts-item.card:last-child{margin-bottom:20px}.posts-item.card .item-body{width:100%;margin:10px 0 0;padding:0}.posts-item.card .item-meta item{font-size:12px}.posts-mini-con .item-heading,.posts-item.card .item-heading{font-size:14px}.posts-item.card .item-heading{min-height:2.8em}.posts-item.card .item-tags{min-height:23px}.posts-item.card .item-thumbnail{width:100%;padding-bottom:var(--posts-card-scale, 70%)}.posts-item.card.style2{background:transparent;box-shadow:none}.posts-item.card.style2:hover{background:var(--main-bg-color, #fff);box-shadow:0 0 10px var(--main-shadow, rgba(116, 116, 116, .08))}.posts-item.card.style3{padding:0}.posts-item.card.style3 .item-thumbnail,.posts-item.card.style3 .item-thumbnail img{border-radius:var(--main-radius, 8px) var(--main-radius, 8px) 0 0}.posts-item.card.style3 .item-body{margin:0;padding:10px}.posts-item.mult-thumb .thumb-items{margin:0 -3px 6px}.posts-item.mult-thumb .thumb-items>span{position:relative;display:inline-block;width:calc(25% - 6px);height:0;margin:0 3px;padding-bottom:calc(var(--posts-list-scale, 70%) / 4)}.posts-item.mult-thumb .thumb-items>span>img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}.posts-item.mult-thumb .thumb-items.contain>span{overflow:hidden;background:var(--main-border-color, rgba(50, 50, 50, .06));border-radius:var(--main-radius, 8px)}.posts-item.mult-thumb .thumb-items.contain>span>img{object-fit:contain;border-radius:0}.posts-item.no_margin{margin:0;border-radius:0;box-shadow:none}.posts-item.no-thumb .item-excerpt{height:auto}.posts-item.no-thumb .item-body{width:100%}.posts-item+.pagenav{margin-top:-15px}.posts-item.card+.pagenav{margin-top:-10px}.no_margin:first-of-type{margin-top:10px;border-radius:var(--main-radius, 8px) var(--main-radius, 8px) 0 0}.no_margin:last-of-type{margin-bottom:15px;border-radius:0 0 var(--main-radius, 8px) var(--main-radius, 8px)}Line truncated
-23
View File
@@ -103,21 +103,6 @@
margin: 0 !important;
}
.item-thumbnail .dplayer.dplayer-thumb {
position: absolute;
inset: 0;
z-index: 1;
padding-bottom: var(--posts-list-scale, 70%);
background: #000;
opacity: 0;
transition: opacity 0.3s;
}
.card .item-thumbnail .dplayer.dplayer-thumb {
padding-bottom: var(--posts-card-scale, 70%);
}
.item-thumbnail .dplayer-thumb video,
.item-thumbnail .swiper-wrapper,
.item-thumbnail img {
position: absolute;
@@ -135,14 +120,6 @@
text-align: center !important;
}
.posts-item.thumb-dplayer-playing .dplayer-thumb {
opacity: 1;
}
.posts-item.thumb-dplayer-playing .abs-center {
opacity: 0;
}
.posts-item .item-heading {
display: -webkit-box;
max-height: 2.8em;
+1 -40
View File
@@ -1,5 +1,5 @@
/**
* AKSRT Misc — related swiper, slide covers, hidden content
* AKSRT Misc — image gradients and hidden content
*/
(function () {
"use strict";
@@ -44,46 +44,7 @@
renderGradientBackground(event.target.closest(".gradient-bg"));
}, true);
function initPostThumbMedia(root) {
var scope = root || document;
scope.querySelectorAll("[data-post-thumb-video]").forEach(function (box) {
if (box.dataset.aksrtThumbVideoBound === "1") return;
box.dataset.aksrtThumbVideoBound = "1";
var video = box.querySelector("video");
if (!video) return;
function loadVideo() {
if (!video.getAttribute("src") && video.dataset.src) {
video.setAttribute("src", video.dataset.src);
video.load();
}
}
function playVideo() {
loadVideo();
var result = video.play();
var postItem = box.closest(".posts-item");
if (postItem) postItem.classList.add("thumb-dplayer-playing");
if (result && typeof result.catch === "function") result.catch(function () {});
}
function pauseVideo() {
video.pause();
var postItem = box.closest(".posts-item");
if (postItem) postItem.classList.remove("thumb-dplayer-playing");
}
var item = box.closest(".item-thumbnail") || box;
item.addEventListener("mouseenter", playVideo);
item.addEventListener("mouseleave", pauseVideo);
item.addEventListener("focusin", playVideo);
item.addEventListener("focusout", pauseVideo);
});
}
function init(root) {
initPostThumbMedia(root);
initGradientBackgrounds(root);
}
+1 -1
View File
@@ -1 +1 @@
(function($,window2,document2){"use strict";function closeNotyf($element){$element.addClass("notyn-out"),window2.setTimeout(function(){$element.remove()},1e3)}function notyf2(message,type,time,id){var $body=jQuery(document2.body);jQuery(".notyn").length||$body.append('<div class="notyn"></div>'),type=type||"success",type==="error"&&(type="danger"),time=time||5e3,time=time<100?time*1e3:time;var idAttribute=id?' id="'+id+'"':"",$notification=jQuery('<div class="noty1"'+idAttribute+'><div class="notyf '+type+'">'+message+"</div></div>"),shouldClose=!id;id&&jQuery("#"+id).length?(jQuery("#"+id).find(".notyf").removeClass().addClass("notyf "+type).html(message),$notification=jQuery("#"+id),shouldClose=!0):jQuery(".notyn").append($notification),shouldClose&&window2.setTimeout(function(){closeNotyf($notification)},time)}jQuery(document2.body).on("click",".noty1",function(){closeNotyf(jQuery(this))}),window2.notyf=notyf2})(jQuery,window,document),(function(window2){"use strict";var allowedKinds={identity:!0,badges:!0,orders:!0,vip:!0},allowedEvents={click:!0,shell:!0,"first-content":!0,ready:!0,"action-start":!0,"action-end":!0,unauthorized:!0,error:!0},sessions=Object.create(null),sequence=0,maxSessions=100;function normalize(value,fallback){var normalized=String(value||fallback||"").toLowerCase().replace(/[^a-z0-9-]/g,"");return normalized||fallback}function now(){return window2.performance&&typeof window2.performance.now=="function"?window2.performance.now():0}function markName(session,event){return"aksrt-modal-"+session.kind+"-"+session.id+"-"+event}function emit(session,event){if(!(!window2.performance||typeof window2.performance.mark!="function")){var name=markName(session,event);if(window2.performance.mark(name),session.marks[event]=name,typeof window2.performance.measure=="function"&&session.marks.click&&event!=="click")try{window2.performance.measure("aksrt-modal-"+session.kind+"-"+session.id+"-click-to-"+event,session.marks.click,name)}catch{}}}function start(kind){var safeKind=normalize(kind,"unknown");allowedKinds[safeKind]||(safeKind="unknown"),sequence+=1;var id=String(sequence),session={id,kind:safeKind,startedAt:now(),marks:Object.create(null)};sessions[id]=session,emit(session,"click");for(var ids=Object.keys(sessions);ids.length>maxSessions;)delete sessions[ids.shift()];return id}function mark(id,event){var session=sessions[String(id||"")],safeEvent=normalize(event,"error");!session||!allowedEvents[safeEvent]||emit(session,safeEvent)}function finish(id){mark(id,"ready")}function fail(id){mark(id,"error")}window2.AksrtModalTelemetry={start,mark,finish,error:fail}})(window),(function(window2){"use strict";function data(){return window2.aksrtData||window2.aksrt||{}}function createIdempotencyKey(){if(window2.crypto&&typeof window2.crypto.randomUUID=="function")return window2.crypto.randomUUID();if(!window2.crypto||typeof window2.crypto.getRandomValues!="function")throw new Error("当前浏览器无法生成安全的操作标识");var bytes=new Uint8Array(16);window2.crypto.getRandomValues(bytes),bytes[6]=bytes[6]&15|64,bytes[8]=bytes[8]&63|128;var hex=Array.prototype.map.call(bytes,function(value){return value.toString(16).padStart(2,"0")}).join("");return hex.slice(0,8)+"-"+hex.slice(8,12)+"-"+hex.slice(12,16)+"-"+hex.slice(16,20)+"-"+hex.slice(20)}function restBase(){var config=data(),raw=config.restUrl||config.apiUrl||config.rest_url||"",siteUrl=config.siteUrl||config.homeUrl||window2.location.origin+"/";return window2.location.protocol==="https:"&&siteUrl.substring(0,5)==="http:"&&(siteUrl="https:"+siteUrl.substring(5)),raw?String(raw).replace(/\/$/,""):String(siteUrl).replace(/\/$/,"")+"/index.php?rest_route=/aksrt/v1"}function appendQuery(url2,query){if(!query)return url2;var parts=[];return typeof query=="string"?parts=query.replace(/^\?/,"").split("&").filter(Boolean):typeof query=="object"&&Object.keys(query).forEach(function(key){query[key]===void 0||query[key]===null||parts.push(encodeURIComponent(key)+"="+encodeURIComponent(String(query[key])))}),parts.length?url2+(url2.indexOf("?")>=0?"&":"?")+parts.join("&"):url2}function url(path,query){path=String(path||"");var inlineQuery="",queryIndex=path.indexOf("?");if(queryIndex>=0&&(inlineQuery=path.slice(queryIndex+1),path=path.slice(0,queryIndex)),/^https?:\/\//i.test(path))return appendQuery(path,query||inlineQuery);path.charAt(0)!=="/"&&(path="/"+path);var base=restBase(),result=(base.indexOf("rest_route=")>=0,base+path);return appendQuery(result,query||inlineQuery)}function headers(options){var config=data(),source=options&&options.headers||{},result={},nonce=config.restNonce||config.nonce||"";return Object.keys(source).forEach(function(key){result[key]=source[key]}),result.Accept||(result.Accept="application/json, text/html;q=0.9, */*;q=0.8"),nonce&&!result["X-WP-Nonce"]&&(result["X-WP-Nonce"]=nonce),options&&options.body!==void 0&&options.body!==null&&!(window2.FormData&&options.body instanceof window2.FormData)&&!result["Content-Type"]&Line truncated
(function($,window2,document2){"use strict";function closeNotyf($element){$element.addClass("notyn-out"),window2.setTimeout(function(){$element.remove()},1e3)}function notyf2(message,type,time,id){var $body=jQuery(document2.body);jQuery(".notyn").length||$body.append('<div class="notyn"></div>'),type=type||"success",type==="error"&&(type="danger"),time=time||5e3,time=time<100?time*1e3:time;var idAttribute=id?' id="'+id+'"':"",$notification=jQuery('<div class="noty1"'+idAttribute+'><div class="notyf '+type+'">'+message+"</div></div>"),shouldClose=!id;id&&jQuery("#"+id).length?(jQuery("#"+id).find(".notyf").removeClass().addClass("notyf "+type).html(message),$notification=jQuery("#"+id),shouldClose=!0):jQuery(".notyn").append($notification),shouldClose&&window2.setTimeout(function(){closeNotyf($notification)},time)}jQuery(document2.body).on("click",".noty1",function(){closeNotyf(jQuery(this))}),window2.notyf=notyf2})(jQuery,window,document),(function(window2){"use strict";var allowedKinds={identity:!0,badges:!0,orders:!0,vip:!0},allowedEvents={click:!0,shell:!0,"first-content":!0,ready:!0,"action-start":!0,"action-end":!0,unauthorized:!0,error:!0},sessions=Object.create(null),sequence=0,maxSessions=100;function normalize(value,fallback){var normalized=String(value||fallback||"").toLowerCase().replace(/[^a-z0-9-]/g,"");return normalized||fallback}function now(){return window2.performance&&typeof window2.performance.now=="function"?window2.performance.now():0}function markName(session,event){return"aksrt-modal-"+session.kind+"-"+session.id+"-"+event}function emit(session,event){if(!(!window2.performance||typeof window2.performance.mark!="function")){var name=markName(session,event);if(window2.performance.mark(name),session.marks[event]=name,typeof window2.performance.measure=="function"&&session.marks.click&&event!=="click")try{window2.performance.measure("aksrt-modal-"+session.kind+"-"+session.id+"-click-to-"+event,session.marks.click,name)}catch{}}}function start(kind){var safeKind=normalize(kind,"unknown");allowedKinds[safeKind]||(safeKind="unknown"),sequence+=1;var id=String(sequence),session={id,kind:safeKind,startedAt:now(),marks:Object.create(null)};sessions[id]=session,emit(session,"click");for(var ids=Object.keys(sessions);ids.length>maxSessions;)delete sessions[ids.shift()];return id}function mark(id,event){var session=sessions[String(id||"")],safeEvent=normalize(event,"error");!session||!allowedEvents[safeEvent]||emit(session,safeEvent)}function finish(id){mark(id,"ready")}function fail(id){mark(id,"error")}window2.AksrtModalTelemetry={start,mark,finish,error:fail}})(window),(function(window2){"use strict";function data(){return window2.aksrtData||window2.aksrt||{}}function createIdempotencyKey(){if(window2.crypto&&typeof window2.crypto.randomUUID=="function")return window2.crypto.randomUUID();if(!window2.crypto||typeof window2.crypto.getRandomValues!="function")throw new Error("当前浏览器无法生成安全的操作标识");var bytes=new Uint8Array(16);window2.crypto.getRandomValues(bytes),bytes[6]=bytes[6]&15|64,bytes[8]=bytes[8]&63|128;var hex=Array.prototype.map.call(bytes,function(value){return value.toString(16).padStart(2,"0")}).join("");return hex.slice(0,8)+"-"+hex.slice(8,12)+"-"+hex.slice(12,16)+"-"+hex.slice(16,20)+"-"+hex.slice(20)}function restBase(){var config=data(),raw=config.restUrl||config.apiUrl||config.rest_url||"",siteUrl=config.siteUrl||config.homeUrl||window2.location.origin+"/";return window2.location.protocol==="https:"&&siteUrl.substring(0,5)==="http:"&&(siteUrl="https:"+siteUrl.substring(5)),raw?String(raw).replace(/\/$/,""):String(siteUrl).replace(/\/$/,"")+"/index.php?rest_route=/aksrt/v1"}function appendQuery(url2,query){if(!query)return url2;var parts=[];return typeof query=="string"?parts=query.replace(/^\?/,"").split("&").filter(Boolean):typeof query=="object"&&Object.keys(query).forEach(function(key){query[key]===void 0||query[key]===null||parts.push(encodeURIComponent(key)+"="+encodeURIComponent(String(query[key])))}),parts.length?url2+(url2.indexOf("?")>=0?"&":"?")+parts.join("&"):url2}function url(path,query){path=String(path||"");var inlineQuery="",queryIndex=path.indexOf("?");if(queryIndex>=0&&(inlineQuery=path.slice(queryIndex+1),path=path.slice(0,queryIndex)),/^https?:\/\//i.test(path))return appendQuery(path,query||inlineQuery);path.charAt(0)!=="/"&&(path="/"+path);var base=restBase(),result=(base.indexOf("rest_route=")>=0,base+path);return appendQuery(result,query||inlineQuery)}function headers(options){var config=data(),source=options&&options.headers||{},result={},nonce=config.restNonce||config.nonce||"";return Object.keys(source).forEach(function(key){result[key]=source[key]}),result.Accept||(result.Accept="application/json, text/html;q=0.9, */*;q=0.8"),nonce&&!result["X-WP-Nonce"]&&(result["X-WP-Nonce"]=nonce),options&&options.body!==void 0&&options.body!==null&&!(window2.FormData&&options.body instanceof window2.FormData)&&!result["Content-Type"]&Line truncated
+4 -3
View File
@@ -143,7 +143,7 @@ if (!function_exists('aksrt_renderer_excerpt_markup')) {
if (!function_exists('aksrt_renderer_curated_images')) {
/** @return string[] */
function aksrt_renderer_curated_images(int $post_id, string $size, int $limit = 8): array {
function aksrt_renderer_curated_images(int $post_id, string $size): array {
$raw = class_exists('\AKSRT\Core\PostMetaBox')
? (string) \AKSRT\Core\PostMetaBox::get_meta_value($post_id, 'featured_slide', '')
: '';
@@ -154,7 +154,7 @@ if (!function_exists('aksrt_renderer_curated_images')) {
$images[] = $image;
}
}
return array_slice($images, 0, $limit);
return $images;
}
}
@@ -179,7 +179,8 @@ if (!function_exists('aksrt_renderer_sized_image')) {
return esc_url_raw($sized);
}
}
return esc_url_raw($image);
// A missing attachment is not a relative image URL. Let the next configured source resolve it.
return ctype_digit($image) ? '' : esc_url_raw($image);
}
}
+8 -6
View File
@@ -78,7 +78,7 @@ if (!function_exists('aksrt_renderer_collect_post_data')) {
'has_real' => !empty($images['has_real']),
'gallery' => $gallery,
'gallery_count' => count($content_images),
'slides' => array_slice((array) $images['slides'], 0, 8),
'slides' => (array) $images['slides'],
'is_slide' => !empty($images['is_slide']),
'video_url' => (string) $images['video_url'],
'is_mult_thumb' => $is_mult_thumb,
@@ -119,16 +119,18 @@ if (!function_exists('aksrt_renderer_thumb')) {
if ($has_video_thumb) {
$muted = !empty($cfg['thumb']['list_thumb_video_mute_s']);
$content .= '<div class="video-thumb-box" video-url="' . esc_url((string) $data['video_url']) . '" data-volume="' . ($muted ? 'none' : '100') . '" data-post-thumb-video>';
$content .= '<div class="video-thumb-box" video-url="' . esc_url((string) $data['video_url']) . '" data-volume="' . ($muted ? 'none' : '100') . '">';
$content .= '<div class="img-thumb"><img' . $default_attr . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['primary'], 'fit-cover radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></div>';
$content .= '<div class="video-thumb"><div class="dplayer dplayer-thumb"><video playsinline loop preload="none"' . ($muted ? ' muted' : '') . ' data-src="' . esc_url((string) $data['video_url']) . '"></video></div></div></div>';
$content .= '<div class="video-thumb"></div></div>';
$format_icon = '<i class="fa fas fa-play-circle em12 mt6 c-white opacity8" aria-hidden="true"></i>';
} elseif ($has_slides) {
$content .= '<div class="relative aksrt-slider"><div class="new-swiper item-thumbnail' . ($is_contain ? ' gradient-background' : '') . '" data-loop="true" data-effect="slide" data-autoplay="1" data-post-thumb-slider><div class="swiper-wrapper">';
$single_slide = count((array) $data['slides']) === 1;
$slide_image_class = 'radius8' . (aksrt_is_lazy('lazy_sider') ? ' swiper-lazy' : '');
$content .= '<div class="relative aksrt-slider"><div class="new-swiper item-thumbnail' . ($is_contain ? ' gradient-background' : '') . ($single_slide ? ' swiper-container-initialized' : '') . '" data-loop="true" data-effect="slide" data-autoplay="1" data-interval="4000"><div class="swiper-wrapper">';
foreach ((array) $data['slides'] as $image) {
$content .= '<div class="swiper-slide' . ($is_contain ? ' gradient-bg' : '') . '"' . ($is_contain ? ' data-opacity="0.2"' : '') . '><a' . $target . ' href="' . esc_url((string) $data['permalink']) . '"><img' . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $image, 'radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></a></div>';
$content .= '<div class="swiper-slide' . ($is_contain ? ' gradient-bg' : '') . '"' . ($is_contain ? ' data-opacity="0.2"' : '') . '><a' . $target . ' href="' . esc_url((string) $data['permalink']) . '"><img' . aksrt_get_lazy_attr('lazy_sider', (string) $image, $slide_image_class) . ' alt="' . esc_attr((string) $data['title']) . '"></a></div>';
}
$content .= '</div><div class="swiper-pagination kaoyou"></div></div></div>';
$content .= '</div>' . ($single_slide ? '' : '<div class="swiper-pagination kaoyou"></div>') . '</div></div>';
$format_icon = '<badge class="b-black opacity8 mt6"><i class="fa fas fa-image mr3" aria-hidden="true"></i>' . count((array) $data['slides']) . '</badge>';
} else {
$content .= '<a' . $target . ' href="' . esc_url((string) $data['permalink']) . '"><img' . $default_attr . aksrt_get_lazy_attr('lazy_posts_thumb', (string) $data['primary'], 'fit-cover radius8') . ' alt="' . esc_attr((string) $data['title']) . '"></a>';
+6 -4
View File
@@ -20,6 +20,7 @@ class InlineStyleBuilder {
$font_family = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::font_family() : 'system';
$logo_width = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::logo_width() : 150;
$sidebar_cfg = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_sidebar_config() : ['width' => 311, 'enabled' => true, 'position' => 'right'];
$list_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_post_list_style_settings() : [];
$content_width = $container_max . 'px';
$container_wide = max(1280, $container_max + 160) . 'px';
@@ -48,8 +49,6 @@ class InlineStyleBuilder {
'--font-heading' => $font_stacks['ui'],
'--aksrt-logo-width' => $logo_width . 'px',
'--nav-height' => '60px',
'--posts-list-scale' => (class_exists('\AKSRT\Settings\Settings') ? (\AKSRT\Settings\Settings::get_post_list_style_settings()['list_list_option']['scale'] ?? 70) : 70) . '%',
'--posts-card-scale' => (class_exists('\AKSRT\Settings\Settings') ? (\AKSRT\Settings\Settings::get_post_list_style_settings()['list_card_option']['scale'] ?? 70) : 70) . '%',
];
echo '<style id="aksrt-runtime-vars">:root{';
@@ -71,7 +70,11 @@ class InlineStyleBuilder {
// 对齐参考主题 zib_head_css():主题色变量与 --main-radius 挂在 body(main.css 的定义层级),
// 夜间主题色仅在单独设置时覆盖 body.dark-theme。
echo '<style id="aksrt-theme-color">body{' . $this->theme_color_vars($primary_color) . '--main-radius:' . (int) $main_radius . 'px;}';
// main.css declares these defaults on body; :root values cannot override them by inheritance.
echo '<style id="aksrt-theme-color">body{' . $this->theme_color_vars($primary_color)
. '--main-radius:' . (int) $main_radius . 'px;'
. '--posts-list-scale:' . (int) ($list_settings['list_list_option']['scale'] ?? 70) . '%;'
. '--posts-card-scale:' . (int) ($list_settings['list_card_option']['scale'] ?? 70) . '%;}';
if ($dark_primary !== '') {
echo 'html.dark body,body.dark-theme{' . $this->theme_color_vars($dark_primary) . '}';
}
@@ -88,7 +91,6 @@ class InlineStyleBuilder {
echo '</style>' . "\n";
if (class_exists('\AKSRT\Settings\Settings')) {
$list_settings = \AKSRT\Settings\Settings::get_post_list_style_settings();
$mobile_meta = sanitize_key((string) ($list_settings['list_meta_show'] ?? 'like'));
if (!in_array($mobile_meta, ['view', 'like', 'comm'], true)) {
$mobile_meta = 'like';
@@ -0,0 +1,66 @@
'use strict';
const assert = require('node:assert/strict');
const fs = require('node:fs');
const path = require('node:path');
const { spawnSync } = require('node:child_process');
const test = require('node:test');
const root = path.resolve(__dirname, '../..');
const result = spawnSync(process.env.PHP_BINARY || 'php', [path.join(__dirname, 'post-thumbnail-render-harness.php')], { cwd: root, encoding: 'utf8' });
assert.equal(result.status, 0, result.stderr || result.stdout);
const rendered = JSON.parse(result.stdout);
test('configured thumbnail ratios override body defaults for both list and card covers', () => {
const main = fs.readFileSync(path.join(root, 'assets/css/main.css'), 'utf8');
assert.match(main, /^body\s*\{[^}]*--posts-card-scale:\s*70%;[^}]*--posts-list-scale:\s*70%;/s);
for (const [scenario, list, card] of [['defaults', 70, 70], ['custom', 100, 56], ['bounds', 50, 200]]) {
const html = rendered.styles[scenario];
const body = html.match(/<style id="aksrt-theme-color">body\{([^}]+)\}/)[1];
assert.match(body, new RegExp(`--posts-list-scale:${list}%;`));
assert.match(body, new RegExp(`--posts-card-scale:${card}%;`));
const rootVariables = html.match(/<style id="aksrt-runtime-vars">:root\{([^}]+)\}/)[1];
assert.doesNotMatch(rootVariables, /--posts-(list|card)-scale/);
assert.equal((html.match(/--posts-list-scale:/g) || []).length, 1);
assert.equal((html.match(/--posts-card-scale:/g) || []).length, 1);
}
});
test('featured attachments use the configured image size and missing attachments fall through in reference order', () => {
assert.equal(rendered.featured.primary, 'https://example.test/featured-large.jpg');
assert.equal(rendered.external.primary, 'https://example.test/external.jpg');
assert.equal(rendered.content.primary, 'https://example.test/content.jpg');
assert.equal(rendered.spare.primary, 'https://example.test/spare.jpg');
assert.equal(rendered.featured.has_real, true);
assert.equal(rendered.external.has_real, true);
assert.equal(rendered.content.has_real, true);
assert.equal(rendered.spare.has_real, false);
assert.deepEqual(rendered.slides, ['https://example.test/featured-medium.jpg']);
});
test('cover and contain images preserve the reference image and gradient wrappers', () => {
assert.match(rendered.cover, /^<div class="item-thumbnail"><a[^>]+><img class="fit-cover radius8"/);
assert.doesNotMatch(rendered.cover, /contain|gradient-bg/);
assert.match(rendered.contain, /^<div class="item-thumbnail contain gradient-bg" data-opacity="0\.2">/);
assert.match(rendered.contain, /src="https:\/\/example\.test\/featured-large\.jpg"/);
});
test('one featured slide stays static and multiple slides retain every image with the reference interval', () => {
assert.match(rendered.single, /new-swiper item-thumbnail swiper-container-initialized/);
assert.doesNotMatch(rendered.single, /swiper-pagination|swiper-button/);
assert.match(rendered.single, /class="lazyload radius8 swiper-lazy"/);
assert.match(rendered.single, /data-src="https:\/\/example.test\/slide.jpg"/);
assert.equal((rendered.multiple.match(/class="swiper-slide gradient-bg"/g) || []).length, 12);
assert.match(rendered.multiple, /data-interval="4000"/);
assert.match(rendered.multiple, /class="swiper-pagination kaoyou"/);
assert.doesNotMatch(rendered.multiple, /swiper-container-initialized/);
});
test('video thumbnails have one runtime player owner and retain the featured image before playback', () => {
assert.match(rendered.video, /class="video-thumb-box" video-url="https:\/\/example.test\/movie.mp4" data-volume="none"/);
assert.match(rendered.video, /class="img-thumb"><img[^>]+featured-large.jpg/);
assert.match(rendered.video, /<div class="video-thumb"><\/div>/);
assert.doesNotMatch(rendered.video, /<video\b|data-post-thumb-video|class="dplayer/);
assert.doesNotMatch(fs.readFileSync(path.join(root, 'assets/js/core/misc.js'), 'utf8'), /initPostThumbMedia|data-post-thumb-video/);
assert.doesNotMatch(fs.readFileSync(path.join(root, 'assets/css/frontend/post-card.css'), 'utf8'), /\.posts-item\.thumb-dplayer-playing|\.dplayer\.dplayer-thumb\s*\{/);
assert.match(fs.readFileSync(path.join(root, 'assets/js/runtime/main.js'), 'utf8'), /thumb_dplayer\(_wid > 640[^\n]+video-thumb-box/);
});
@@ -0,0 +1,109 @@
<?php
/** Render thumbnail settings and image markup without a WordPress installation. */
declare(strict_types=1);
namespace AKSRT\Settings {
final class Settings {
public static array $values = [];
public static function get_all(): array { return self::$values; }
public static function get_post_list_style_settings(): array { return PostDisplay::get_post_list_style_settings(); }
public static function logo_url(): string { return ''; }
public static function logo_dark_url(): string { return ''; }
public static function favicon_url(): string { return ''; }
public static function theme_color(): string { return '#f04494'; }
public static function dark_theme_color(): string { return '#abcdef'; }
public static function main_radius(): int { return 8; }
public static function container_max_width(): int { return 1200; }
public static function font_family(): string { return 'system'; }
public static function font_family_custom(): string { return ''; }
public static function logo_width(): int { return 150; }
public static function get_sidebar_config(): array { return ['width' => 311]; }
public static function get_header_theme_config(): array { return []; }
public static function background_css(string $key): string { return ''; }
}
}
namespace AKSRT\Core {
final class PostMetaBox {
public static array $meta = [];
public static function get_meta_value(int $id, string $key, $default = '') { return self::$meta[$key] ?? $default; }
}
}
namespace {
define('ABSPATH', dirname(__DIR__, 2) . DIRECTORY_SEPARATOR);
set_error_handler(static function (int $severity, string $message, string $file, int $line): bool {
if (!(error_reporting() & $severity)) return false;
throw new \ErrorException($message, 0, $severity, $file, $line);
});
function __($text, $domain = ''): string { return (string) $text; }
function esc_html($text): string { return htmlspecialchars((string) $text, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); }
function esc_attr($text): string { return esc_html($text); }
function esc_url($url): string { return esc_attr($url); }
function esc_url_raw($url): string { return (string) $url; }
function sanitize_key($value): string { return preg_replace('/[^a-z0-9_-]/', '', strtolower((string) $value)); }
function wp_kses_post($html): string { return (string) $html; }
function strip_shortcodes($content): string { return (string) $content; }
function wp_strip_all_tags($content): string { return strip_tags((string) $content); }
function get_post_thumbnail_id($id): int { return $GLOBALS['featured_id']; }
function attachment_url_to_postid($url): int { return 0; }
function wp_get_attachment_image_url($id, $size) {
return $id === 42 ? 'https://example.test/featured-' . $size . '.jpg' : false;
}
function get_post_field($field, $id, $context = ''): string { return $GLOBALS['post_content']; }
function get_the_category($id): array { return []; }
function get_post_format($id = null) { return false; }
function aksrt_get_lazy_thumb($size = ''): string { return 'https://example.test/placeholder.svg'; }
function aksrt_is_lazy($key): bool { return $key === 'lazy_sider'; }
function aksrt_get_lazy_attr($key, $src, $class = ''): string {
if (aksrt_is_lazy($key)) {
return ' class="lazyload ' . esc_attr($class) . '" src="' . aksrt_get_lazy_thumb() . '" data-src="' . esc_url($src) . '"';
}
return ' class="' . esc_attr($class) . '" src="' . esc_url($src) . '"';
}
require ABSPATH . 'src/Settings/PostDisplay.php';
require ABSPATH . 'src/Frontend/InlineStyleBuilder.php';
require ABSPATH . 'inc/helpers/posts-renderer/config.php';
require ABSPATH . 'inc/helpers/posts-renderer/post-data.php';
$styles = [];
foreach (['defaults' => [], 'custom' => ['list_list_option' => ['scale' => 100], 'list_card_option' => ['scale' => 56]], 'bounds' => ['list_list_option' => ['scale' => 1], 'list_card_option' => ['scale' => 900]]] as $name => $values) {
\AKSRT\Settings\Settings::$values = $values;
ob_start();
(new \AKSRT\Frontend\InlineStyleBuilder())->output();
$styles[$name] = (string) ob_get_clean();
}
$GLOBALS['featured_id'] = 42;
$GLOBALS['post_content'] = '<p><img src="https://example.test/content.jpg"></p>';
\AKSRT\Core\PostMetaBox::$meta = ['thumbnail_url' => 'https://example.test/external.jpg'];
$cfg = ['thumb' => ['thumb_postfirstimg_size' => 'large', 'thumb_postfirstimg_s' => true, 'spare_thumbnail' => ['https://example.test/spare.jpg']]];
$featured = aksrt_renderer_resolve_images(1, $cfg);
$GLOBALS['featured_id'] = 999;
$external = aksrt_renderer_resolve_images(1, $cfg);
\AKSRT\Core\PostMetaBox::$meta = [];
$content = aksrt_renderer_resolve_images(1, $cfg);
$GLOBALS['post_content'] = '';
$spare = aksrt_renderer_resolve_images(1, $cfg);
\AKSRT\Core\PostMetaBox::$meta = ['featured_slide' => '999,42'];
$slides = aksrt_renderer_curated_images(1, 'medium');
$data = [
'post_id' => 1, 'primary' => $featured['primary'], 'has_real' => true,
'permalink' => 'https://example.test/post/', 'title' => 'Featured image',
'video_url' => '', 'slides' => [], 'gallery_count' => 0,
];
$cover = aksrt_renderer_thumb($data, ['thumb' => ['list_thumb_fit' => '']]);
$contain = aksrt_renderer_thumb($data, ['thumb' => ['list_thumb_fit' => 'contain']]);
$data['is_slide'] = true;
$data['slides'] = ['https://example.test/slide.jpg'];
$single = aksrt_renderer_thumb($data, ['thumb' => []]);
\AKSRT\Core\PostMetaBox::$meta = ['featured_slide' => implode(',', array_fill(0, 12, '42'))];
$data['slides'] = aksrt_renderer_curated_images(1, 'large');
$multiple = aksrt_renderer_thumb($data, ['thumb' => ['list_thumb_fit' => 'contain']]);
$data['video_url'] = 'https://example.test/movie.mp4';
$video = aksrt_renderer_thumb($data, ['thumb' => ['list_thumb_video_s' => true, 'list_thumb_video_mute_s' => true]]);
echo json_encode(compact('styles', 'featured', 'external', 'content', 'spare', 'slides', 'cover', 'contain', 'single', 'multiple', 'video'), JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES);
}
@@ -165,7 +165,9 @@ test('list, card, media, badge and Mini DOM follow dedicated legacy structures',
assert.match(data, /relative aksrt-slider.*new-swiper item-thumbnail/s);
assert.match(data, /swiper-slide.*gradient-bg.*data-opacity="0\.2"/s);
assert.match(data, /\$fit = \$is_contain && !\$has_slides \? ' contain gradient-bg' : ''/);
assert.match(data, /video-thumb-box.*data-post-thumb-video/s);
assert.match(data, /video-thumb-box.*video-url=/s);
assert.match(data, /<div class="video-thumb"><\/div>/);
assert.doesNotMatch(data, /data-post-thumb-video/);
assert.match(data, /class="thumb-items/);
assert.match(data, /empty\(\$cfg\['is_category'\]\).*in_array\('cat'/s);
assert.match(data, /empty\(\$cfg\['is_tag'\]\).*in_array\('tag'/s);
@@ -372,10 +374,10 @@ test('AJAX pagination can recover, caps auto loading and rehydrates appended med
assert.match(homepage, /aksrt_render_pagination\(\$query,[\s\S]*?'query_context'\s*=>\s*\$contract\['query_context'\]/);
assert.doesNotMatch(homepage, /href="javascript:;" class="ajax-next aksrt-load-more-btn"/);
assert.match(ajaxList, /if \(link\.closest\("\[data-aksrt-pagination\], \.aksrt-comment-pagination"\)\) return;/);
assert.match(media, /thumb-dplayer-playing/);
assert.match(read('assets/js/runtime/main.js'), /thumb_dplayer\(_wid > 640/);
assert.doesNotMatch(media, /new Swiper|data-post-thumb-slider/);
assert.match(read('assets/js/runtime/main.min.js'), /new-swiper/);
assert.match(media, /data-post-thumb-video/);
assert.doesNotMatch(media, /data-post-thumb-video|initPostThumbMedia/);
assert.match(media, /window\.Grade\(container/);
assert.match(media, /linear-gradient\(135deg/);
assert.match(media, /aksrtGradientState/);