chore: 部分代码优化 (#1674)

This commit is contained in:
Henry Wang
2019-03-04 11:26:09 +00:00
committed by DIYgod
parent 67f41eabb3
commit e72f82e983
101 changed files with 138 additions and 108 deletions

View File

@@ -94,7 +94,7 @@ module.exports = {
if (item.pictures) {
item.pictures.forEach((pic) => {
if (pic.format === 'gif') {
description += `<img src="${pic.picUrl.split('?imageMogr2/')[0]}"></picture>`;
description += `<img referrerpolicy="no-referrer" 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
@@ -110,7 +110,9 @@ module.exports = {
break;
}
const imgUrl = pic.picUrl.match(/\.[a-z0-9]+?\?imageMogr2/) ? pic.picUrl.split('?imageMogr2/')[0] : pic.picUrl.replace(/thumbnail\/.+/, '');
description += `<br/><picture><source srcset="${pic.picUrl.split('/thumbnail/')[0]}/strip/format/webp" type="image/webp"><source srcset="${imgUrl}" type="image/${type}"><img src="${imgUrl}"></picture>`;
description += `<br/><picture><source srcset="${
pic.picUrl.split('/thumbnail/')[0]
}/strip/format/webp" type="image/webp"><source srcset="${imgUrl}" type="image/${type}"><img referrerpolicy="no-referrer" src="${imgUrl}"></picture>`;
}
});
}