mirror of
https://github.com/d0zingcat/BroadcastChannel.git
synced 2026-05-13 23:16:46 +00:00
feat: enhance image loading and sanitization
- Standardized image loading to lazy for consistency in modal previews - Expanded allowed attributes for sanitization to support additional image properties - Introduced an exclusive filter to exclude specific images by class during sanitization
This commit is contained in:
@@ -41,7 +41,7 @@ function getImages($, item, { staticProxy, id, index, title }) {
|
||||
<img src="${staticProxy + url}" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
|
||||
</button>
|
||||
<button class="image-preview-button modal" id="${popoverId}" popovertarget="${popoverId}" popovertargetaction="hide" popover>
|
||||
<img class="modal-img" src="${staticProxy + url}" alt="${title}" loading="${index > 15 ? 'eager' : 'lazy'}" />
|
||||
<img class="modal-img" src="${staticProxy + url}" alt="${title}" loading="lazy" />
|
||||
</button>
|
||||
`
|
||||
})?.get()
|
||||
|
||||
@@ -25,9 +25,13 @@ export async function GET(Astro) {
|
||||
content: sanitizeHtml(item.content, {
|
||||
allowedTags: sanitizeHtml.defaults.allowedTags.concat(['img', 'video', 'audio']),
|
||||
allowedAttributes: {
|
||||
...sanitizeHtml.defaults.allowedAttributes,
|
||||
video: ['src', 'width', 'height', 'poster'],
|
||||
audio: ['src', 'controls'],
|
||||
img: ['src', 'width', 'height', 'loading'],
|
||||
img: ['src', 'srcset', 'alt', 'title', 'width', 'height', 'loading', 'class'],
|
||||
},
|
||||
exclusiveFilter(frame) {
|
||||
return frame.tag === 'img' && frame.attribs?.class?.includes('modal-img')
|
||||
},
|
||||
}),
|
||||
})),
|
||||
|
||||
Reference in New Issue
Block a user