Embed
This package will get metadata (title, image, etc.) for a given URL and use it to prefill other form fields.
Config
You’ll need to configure the embedProvider
setting as well as at least one provider (unless you’re using the builtin
method).
In your private settings:
1 | "embedProvider": "builtin", |
1 | "embedProvider": "embedAPI", |
Possible providers include:
Form Component
Inside forms, you can use the EmbedURL
component to display a special URL field that will prefill other fields based on its own value whenever that value changes.
Prefillable fields include:
title
: the title of the linked URL.body
: the description of the URL.thumbnailUrl
: a thumbnail image of the URL.media
: a media embed, for example a YouTube video embed.sourceName
: the source name, for example the name of a YouTube channel.sourceUrl
: the source URL, for example the URL of a YouTube channel.
Here’s an example of including these fields as custom fields on the Posts
collection (which already includes its own title
and body
):
1 | import Posts from '../posts/index.js'; |
Mutations
The package exposes the following GraphQL mutation:
1 | getEmbedData(url: String) : JSON |
Custom Providers
To add a new provider, follow this structure to implement the Embed.myProvider.getData
function:
1 | import { Embed } from 'meteor/vulcan:embed'; |
Then set the embedProvider
setting to myProvider
.
Callbacks
You can use callbacks to generate embedded media server-side:
1 | /* |