mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 18:30:53 +08:00
Add a thorough MIME image type check (#753)
#555 https://github.com/DIYgod/RSSHub/issues/555#issuecomment-422837421
This commit is contained in:
@@ -84,12 +84,28 @@ module.exports = {
|
||||
|
||||
// 5. 图片
|
||||
if (item.pictures) {
|
||||
item.pictures.forEach(
|
||||
(pic) =>
|
||||
(description += `<br/><picture><source srcset="${pic.picUrl.split('/thumbnail/')[0]}/strip/format/webp" type="image/webp"><source srcset="${pic.picUrl.split('?imageMogr2/')[0]}" type="image/jpeg"><img src="${
|
||||
item.pictures.forEach((pic) => {
|
||||
if (pic.format === 'gif') {
|
||||
description += `<img src="${pic.picUrl.split('?imageMogr2/')[0]}"></picture>`;
|
||||
} else {
|
||||
// jpeg, bmp, png, gif, webp
|
||||
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
|
||||
let type = 'jpeg';
|
||||
switch (pic.format) {
|
||||
case 'bmp':
|
||||
type = 'bmp';
|
||||
break;
|
||||
case 'png':
|
||||
type = 'png';
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
description += `<br/><picture><source srcset="${pic.picUrl.split('/thumbnail/')[0]}/strip/format/webp" type="image/webp"><source srcset="${
|
||||
pic.picUrl.split('?imageMogr2/')[0]
|
||||
}"></picture>`)
|
||||
);
|
||||
}" type="image/${type}"><img src="${pic.picUrl.split('?imageMogr2/')[0]}"></picture>`;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// rss标题
|
||||
|
||||
Reference in New Issue
Block a user