mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-10-25 10:14:31 +08:00
feat: add width and height to img
This commit is contained in:
@@ -57,7 +57,7 @@ async function handler(ctx) {
|
||||
const items = resp.MediaContents.map((item) => {
|
||||
const ssd = item.Ssd;
|
||||
const link = `${apiUrl}${item.ImageContent.Image.Url.match(/\/th\?id=[^_]+_[^_]+/)[0].replace(/(_\d+x\d+\.webp)$/i, '')}_${type}.jpg`;
|
||||
let description = `<img src="${link}" alt="Article Cover Image" style="display: block; margin: 0 auto;"><br>`;
|
||||
let description = `<img width="1920" height="1080" src="${link}" alt="Article Cover Image" style="display: block; margin: 0 auto;"><br>`;
|
||||
if (story) {
|
||||
description += `<b>${item.ImageContent.Headline}</b>`;
|
||||
description += `<i>${item.ImageContent.QuickFact.MainText}</i><br>`;
|
||||
|
||||
@@ -2,15 +2,15 @@ import { config } from '@/config';
|
||||
|
||||
export default {
|
||||
getImgs(illust) {
|
||||
const images = [];
|
||||
const images: string[] = [];
|
||||
if (illust.meta_pages?.length) {
|
||||
for (const page of illust.meta_pages) {
|
||||
const original = page.image_urls.original.replace('https://i.pximg.net', config.pixiv.imgProxy);
|
||||
images.push(`<p><img src="${original}"/></p>`);
|
||||
images.push(`<p><img src="${original}" width="${page.width}" height="${page.height}" /></p>`);
|
||||
}
|
||||
} else if (illust.meta_single_page.original_image_url) {
|
||||
const original = illust.meta_single_page.original_image_url.replace('https://i.pximg.net', config.pixiv.imgProxy);
|
||||
images.push(`<p><img src="${original}"/></p>`);
|
||||
images.push(`<p><img src="${original}" width="${illust.width}" height="${illust.height}" /></p>`);
|
||||
}
|
||||
return images;
|
||||
},
|
||||
|
||||
@@ -428,7 +428,9 @@ async function handler(ctx) {
|
||||
const background = $node.css('background-image');
|
||||
const backgroundUrl = background && background.match(/url\('(.*)'\)/);
|
||||
const backgroundUrlSrc = backgroundUrl && backgroundUrl[1];
|
||||
tag_media += backgroundUrlSrc ? `<img src="${backgroundUrlSrc}">` : '';
|
||||
const width = Number.parseFloat($node.css('width') || '0');
|
||||
const height = ((Number.parseFloat($node.find('.tgme_widget_message_photo').css('padding-top') || '0') / 100) * width).toFixed(2);
|
||||
tag_media += backgroundUrlSrc ? `<img width="${width}" height="${height}" src="${backgroundUrlSrc}">` : '';
|
||||
}
|
||||
if (tag_media) {
|
||||
tag_media_all += tag_media;
|
||||
|
||||
@@ -104,7 +104,7 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
||||
if (!readable) {
|
||||
content += '<br>';
|
||||
}
|
||||
content += `<video src='${video.url}' ${gifAutoPlayAttr} controls='controls' poster='${getOriginalImg(media.media_url_https)}' ${extraAttrs}></video>`;
|
||||
content += `<video width="${media.sizes.large.w}" height="${media.sizes.large.h}" src='${video.url}' ${gifAutoPlayAttr} controls='controls' poster='${getOriginalImg(media.media_url_https)}' ${extraAttrs}></video>`;
|
||||
}
|
||||
|
||||
return content;
|
||||
@@ -142,6 +142,9 @@ const ProcessFeed = (ctx, { data = [] }, params = {}) => {
|
||||
content += `height="${heightOfPics}" `;
|
||||
style += `height: ${heightOfPics}px;`;
|
||||
}
|
||||
if (widthOfPics <= 0 && heightOfPics <= 0) {
|
||||
content += `width="${media.sizes.large.w}" height="${media.sizes.large.h}" `;
|
||||
}
|
||||
content += ` style="${style}" ` + `${readable ? 'hspace="4" vspace="8"' : ''} src="${originalImg}">`;
|
||||
if (addLinkForPics) {
|
||||
content += `</a>`;
|
||||
|
||||
Reference in New Issue
Block a user