mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-24 23:42:40 +08:00
feat: add img width height for bilibili/dynamic weibo/user xiaohongshu/user routes
This commit is contained in:
@@ -126,26 +126,48 @@ const getIframe = (data?: Modules, embed: boolean = true) => {
|
||||
};
|
||||
|
||||
const getImgs = (data?: Modules) => {
|
||||
const imgUrls: string[] = [];
|
||||
const imgUrls: {
|
||||
url: string;
|
||||
width?: number;
|
||||
height?: number;
|
||||
}[] = [];
|
||||
const major = data?.module_dynamic?.major;
|
||||
if (!major) {
|
||||
return '';
|
||||
}
|
||||
// 动态图片
|
||||
if (major.opus?.pics?.length) {
|
||||
imgUrls.push(...major.opus.pics.map((e) => e.url));
|
||||
imgUrls.push(
|
||||
...major.opus.pics.map((e) => ({
|
||||
url: e.url,
|
||||
width: e.width,
|
||||
height: e.height,
|
||||
}))
|
||||
);
|
||||
}
|
||||
// 专栏封面
|
||||
if (major.article?.covers?.length) {
|
||||
imgUrls.push(...major.article.covers);
|
||||
imgUrls.push(
|
||||
...major.article.covers.map((e) => ({
|
||||
url: e,
|
||||
}))
|
||||
);
|
||||
}
|
||||
// 相簿
|
||||
if (major.draw?.items?.length) {
|
||||
imgUrls.push(...major.draw.items.map((e) => e.src));
|
||||
imgUrls.push(
|
||||
...major.draw.items.map((e) => ({
|
||||
url: e.src,
|
||||
width: e.width,
|
||||
height: e.height,
|
||||
}))
|
||||
);
|
||||
}
|
||||
// 正在直播的动态
|
||||
if (major.live_rcmd?.content) {
|
||||
imgUrls.push(JSON.parse(major.live_rcmd.content)?.live_play_info?.cover);
|
||||
imgUrls.push({
|
||||
url: JSON.parse(major.live_rcmd.content)?.live_play_info?.cover,
|
||||
});
|
||||
}
|
||||
const type = major.type.replace('MAJOR_TYPE_', '').toLowerCase();
|
||||
if (major[type]?.cover) {
|
||||
@@ -153,7 +175,7 @@ const getImgs = (data?: Modules) => {
|
||||
}
|
||||
return imgUrls
|
||||
.filter(Boolean)
|
||||
.map((url) => `<img src="${url}">`)
|
||||
.map((img) => `<img src="${img.url}" ${img.width ? `width="${img.width}"` : ''} ${img.height ? `height="${img.height}"` : ''}>`)
|
||||
.join('');
|
||||
};
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ const weiboUtils = {
|
||||
widthOfPics: fallback(params.widthOfPics, queryToInteger(routeParams.widthOfPics), -1),
|
||||
heightOfPics: fallback(params.heightOfPics, queryToInteger(routeParams.heightOfPics), -1),
|
||||
sizeOfAuthorAvatar: fallback(params.sizeOfAuthorAvatar, queryToInteger(routeParams.sizeOfAuthorAvatar), 48),
|
||||
showEmojiInDescription: fallback(params.showEmojiInDescription, queryToInteger(routeParams.showEmojiInDescription), true),
|
||||
showEmojiInDescription: fallback(params.showEmojiInDescription, queryToInteger(routeParams.showEmojiInDescription), false),
|
||||
showLinkIconInDescription: fallback(params.showLinkIconInDescription, queryToInteger(routeParams.showLinkIconInDescription), true),
|
||||
preferMobileLink: fallback(params.preferMobileLink, queryToBoolean(routeParams.preferMobileLink), false),
|
||||
};
|
||||
@@ -157,13 +157,13 @@ const weiboUtils = {
|
||||
let style = '';
|
||||
html += '<img ';
|
||||
html += readable ? 'vspace="8" hspace="4"' : '';
|
||||
if (widthOfPics >= 0) {
|
||||
html += ` width="${widthOfPics}"`;
|
||||
style += `width: ${widthOfPics}px;`;
|
||||
if (item.large.geo.width || widthOfPics >= 0) {
|
||||
html += ` width="${item.large.geo.width || widthOfPics}"`;
|
||||
style += `width: ${item.large.geo.width || widthOfPics}px;`;
|
||||
}
|
||||
if (heightOfPics >= 0) {
|
||||
html += ` height="${heightOfPics}"`;
|
||||
style += `height: ${heightOfPics}px;`;
|
||||
if (item.large.geo.height || heightOfPics >= 0) {
|
||||
html += ` height="${item.large.geo.height || heightOfPics}"`;
|
||||
style += `height: ${item.large.geo.height || heightOfPics}px;`;
|
||||
}
|
||||
html += ` style="${style}"` + ' src="' + item.large.url + '">';
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ async function getUserFeeds(url: string, category: string) {
|
||||
title: noteCard.displayTitle,
|
||||
link: new URL(noteCard.noteId || id, url).toString(),
|
||||
guid: noteCard.displayTitle,
|
||||
description: `<img src ="${noteCard.cover.infoList.pop().url}"><br>${noteCard.displayTitle}`,
|
||||
description: `<img src ="${noteCard.cover.infoList.pop().url} width="${noteCard.cover.width}" height="${noteCard.cover.height}"><br>${noteCard.displayTitle}`,
|
||||
author: noteCard.user.nickname,
|
||||
upvotes: noteCard.interactInfo.likedCount,
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user