mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
pre-cache thumbnail
This commit is contained in:
parent
9f1babf787
commit
396ada28b8
5 changed files with 11 additions and 8 deletions
|
|
@ -31,6 +31,7 @@ import { ANTHROPIC_MODEL, OPENAI_MODEL } from '../../utils/ai'
|
|||
import { analytics } from '../../utils/analytics'
|
||||
import { enqueueSendEmail } from '../../utils/createTask'
|
||||
import { wordsCount } from '../../utils/helpers'
|
||||
import { createThumbnailProxyUrl } from '../../utils/imageproxy'
|
||||
import { logger } from '../../utils/logger'
|
||||
import { htmlToMarkdown, markdownToHtml } from '../../utils/parser'
|
||||
import { uploadToBucket } from '../../utils/uploads'
|
||||
|
|
@ -649,7 +650,9 @@ const findThumbnail = async (
|
|||
|
||||
try {
|
||||
for (const thumbnail of thumbnails) {
|
||||
const size = await getImageSize(thumbnail)
|
||||
const proxyUrl = createThumbnailProxyUrl(thumbnail)
|
||||
// pre-cache thumbnail first if exists
|
||||
const size = await getImageSize(proxyUrl)
|
||||
if (!size) {
|
||||
continue
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
findLibraryItemById,
|
||||
updateLibraryItem,
|
||||
} from '../services/library_item'
|
||||
import { createThumbnailUrl } from '../utils/imageproxy'
|
||||
import { createThumbnailProxyUrl } from '../utils/imageproxy'
|
||||
import { logger } from '../utils/logger'
|
||||
|
||||
interface Data {
|
||||
|
|
@ -137,7 +137,7 @@ export const findThumbnail = async (data: Data) => {
|
|||
|
||||
const thumbnail = item.thumbnail
|
||||
if (thumbnail) {
|
||||
const proxyUrl = createThumbnailUrl(thumbnail)
|
||||
const proxyUrl = createThumbnailProxyUrl(thumbnail)
|
||||
// pre-cache thumbnail first if exists
|
||||
const image = await fetchImage(proxyUrl)
|
||||
if (!image) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ import {
|
|||
import { findActiveUser } from '../../services/user'
|
||||
import createHttpTaskWithToken from '../../utils/createTask'
|
||||
import { cleanUrl } from '../../utils/helpers'
|
||||
import { createThumbnailUrl } from '../../utils/imageproxy'
|
||||
import { createThumbnailProxyUrl } from '../../utils/imageproxy'
|
||||
import { logger } from '../../utils/logger'
|
||||
import { RSSRefreshContext } from './refreshAllFeeds'
|
||||
|
||||
|
|
@ -367,7 +367,7 @@ const createItemWithFeedContent = async (
|
|||
})
|
||||
|
||||
const thumbnail = getThumbnail(item)
|
||||
const previewImage = thumbnail && createThumbnailUrl(thumbnail)
|
||||
const previewImage = thumbnail && createThumbnailProxyUrl(thumbnail)
|
||||
const url = cleanUrl(item.link)
|
||||
|
||||
const user = await findActiveUser(userId)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { createAndSaveLabelsInLibraryItem } from '../../services/labels'
|
|||
import { createOrUpdateLibraryItem } from '../../services/library_item'
|
||||
import { parsedContentToLibraryItem } from '../../services/save_page'
|
||||
import { cleanUrl, generateSlug } from '../../utils/helpers'
|
||||
import { createThumbnailUrl } from '../../utils/imageproxy'
|
||||
import { createThumbnailProxyUrl } from '../../utils/imageproxy'
|
||||
import { logger } from '../../utils/logger'
|
||||
import {
|
||||
ParsedContentPuppeteer,
|
||||
|
|
@ -72,7 +72,7 @@ export function followingServiceRouter() {
|
|||
|
||||
const feedUrl = req.body.addedToFollowingBy
|
||||
const thumbnail =
|
||||
req.body.thumbnail && createThumbnailUrl(req.body.thumbnail)
|
||||
req.body.thumbnail && createThumbnailProxyUrl(req.body.thumbnail)
|
||||
const url = cleanUrl(req.body.url)
|
||||
|
||||
const preparedDocument: PreparedDocumentInput = {
|
||||
|
|
|
|||
|
|
@ -28,5 +28,5 @@ export function createImageProxyUrl(
|
|||
return `${env.imageProxy.url}/${width}x${height},s${signature}/${url}`
|
||||
}
|
||||
|
||||
export const createThumbnailUrl = (url: string): string =>
|
||||
export const createThumbnailProxyUrl = (url: string): string =>
|
||||
createImageProxyUrl(url, 320, 320)
|
||||
|
|
|
|||
Loading…
Reference in a new issue