Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling of dynamic images #258

Open
deankroker opened this issue Jan 17, 2025 · 2 comments
Open

Handling of dynamic images #258

deankroker opened this issue Jan 17, 2025 · 2 comments

Comments

@deankroker
Copy link

deankroker commented Jan 17, 2025

I'm trying to get open-graph-scraper to return OG images for a Loom video.

E.g.: if I call the below function with the URL https://www.loom.com/share/473fad25ebd24b5ea8091503253dfecf,

'use server'

import ogs from 'open-graph-scraper'

export async function fetchOgData(url: string) {
    try {
        const { result } = await ogs({ url })
        console.log('URL:', url)
        console.log('Full OG Result:', JSON.stringify(result, null, 2))

        return {
            success: true,
            data: {
                title: result.ogTitle,
                description: result.ogDescription,
                image: result.ogImage?.[0]?.url,
                url: result.ogUrl
            }
        }
    } catch (error) {
        console.error('OG Scrape Error:', error)
        return { success: false, error: 'Failed to fetch OG data' }
    }
}

data.image returns https://cdn.loom.com/assets/img/og/loom-banner.png, whereas if I paste the same URL on opengraph.xyz, you'll see the og:image property returns https://cdn.loom.com/sessions/thumbnails/473fad25ebd24b5ea8091503253dfecf-1650653926695.gif.

Is this expected behavior for dynamic routes or is there a way to properly parse OG images for sites like Loom?

open-graph-scraper returns static placeholder:

Image

iMessage, FB tools, and opengraph.xyz returns correct image for URL:

Image

Thanks in advance for your help, this is my first time using your API :) hopefully this is just a pebkac error :)

@jshemas
Copy link
Owner

jshemas commented Jan 18, 2025

Hello. This is working as design. https://cdn.loom.com/assets/img/og/loom-banner.pn is the og:image of that page.

Image

I'm guessing those other tools have something hardcoded for this website to point to the other image instead of the og tag.

@deankroker
Copy link
Author

thanks for the reply @jshemas -- but most of the OG generators don't reference the static HTML, for example, if you paste that loom video URL into iMessage or the OG checker that I linked above that Meta provides, you'll see it loads the dynamic OG Image. Lots of services like Vercel have OG runtime support. Does open-graph-scraper support dynamic runtimes?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants