Skip to content

Commit

Permalink
Fetch smaller images from Cloudinary
Browse files Browse the repository at this point in the history
  • Loading branch information
barryf committed Nov 24, 2024
1 parent 4e8fa30 commit 2669529
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/events/process-post/syndicate/bluesky.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@ async function syndicate (post) {
const photos = post.properties.photo.slice(0, 4) // max 4
for (const photo of photos) {
const url = (typeof photo === 'string') ? photo : photo.value
const starts = 'https://res.cloudinary.com/barryf/image/upload/'
if (url.startsWith(starts)) {
url.replace(starts, `${starts}h_768/`)
}
const alt = (typeof photo === 'string') ? '' : photo.alt
const response = await fetch(url)
// if (!response.ok) continue
if (!response.ok) continue
const arrayBuffer = await response.arrayBuffer()
const buffer = Buffer.from(arrayBuffer)
const { data } = await agent.uploadBlob(
Expand All @@ -43,7 +47,6 @@ async function syndicate (post) {
images
}
}
console.log('richPost', richPost)

const response = await agent.post(richPost)
if (!response.ok) return
Expand Down

0 comments on commit 2669529

Please sign in to comment.