-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to use image from Local image? #65
Comments
this worked for me: ---
import {getImage} from 'astro:assets'
...
const cover = await getImage({ src: imagePath, format:'webp' })
const absCoverUrl = new URL(cover.src, Astro.site)
---
<div>
<SEO
openGraph={{
basic: {
image: absCoverUrl,
},
...
|
@xiaoxinghu Thanks for pitching in here! @krisnaw Does @xiaoxinghu code fix your problem? |
Okay, it works, although the generated URL looks weird. Thanks, @xiaoxinghu 🙏 |
How to tackle the same for an SVG? |
@xiaoxinghu tip #65 (comment) doesn't work with experimental assets, or I last I couldn't make it work. I was expecting to generate an |
@millette This only happens on the dev server, if you build/preview it should generate a To use a local image you can import it and use it like this: ---
import { SEO } from 'astro-seo'
import cat from '../cat.png'
---
<SEO openGraph={{
basic: {
image: cat,
type: 'type',
title: 'My cat Levi'
}
}}/> If you are using |
On Astro file, this is how to load image from local image
index.astro
<!-- Local image stored at public/assets/stars.png --> <img src="/assets/stars.png" alt="A starry night sky.">
Using similar value on the image Propname doesn't work
The text was updated successfully, but these errors were encountered: