add placeholder for inline images

This commit is contained in:
amirhouieh 2024-01-25 12:51:32 +00:00
parent 4e7f3ad9f9
commit f80c41c791
No known key found for this signature in database
GPG Key ID: 96A18489765C51DD
2 changed files with 8 additions and 4 deletions

View File

@ -4,7 +4,7 @@
<title>Hashing It Out</title>
<link>https://dev-press.logos.co/rss/hashing-it-out.xml</link>
<description>Hashing It Out is a highly-technical bi-weekly show that brings you the pioneering developers driving the Cypherpunk movement. In each show we take a deep dive through privacy, sovereignty, and network state technology with some of web3&apos;s most influential innovators.</description>
<lastBuildDate>Thu, 25 Jan 2024 12:37:56 GMT</lastBuildDate>
<lastBuildDate>Thu, 25 Jan 2024 12:40:22 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>

View File

@ -100,10 +100,10 @@ export const transformStrapiHtmlContent = async ({
const tagName = node.tagName.toLowerCase()
const isFigure = tagName === 'figure'
const isMedia = isFigure && !!node.querySelector('oembed')
const isImage = isFigure && !isMedia && !!node.querySelector('img')
const isImage = !!node.querySelector('img')
const empty = node.text.length === 0
if (!isFigure && empty) continue
if (!isFigure && !isImage && empty) continue
blockIndex++
@ -116,7 +116,8 @@ export const transformStrapiHtmlContent = async ({
const caption = text
const alt = image.getAttribute('alt') || ''
const url = image.getAttribute('src') || ''
let url = image.getAttribute('src') || ''
url = url.slice(url.indexOf('/uploads/'))
const width = parseInt(image.getAttribute('width') || '0', 10)
const height = parseInt(image.getAttribute('height') || '0', 10)
@ -130,6 +131,9 @@ export const transformStrapiHtmlContent = async ({
alt: alt || caption,
labels: [],
order: blockIndex,
placeholder: isVercel()
? getStrapiImageUrlBySize('thumbnail', url)
: await placeholderService.pixelate(url),
url: url.startsWith('/') ? transformStrapiImageUrl(url) : url,
footnotes,
})