🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!
Guides & Tutorials October 20, 2026

How to Add a Video and Link Preview Field to Gravity Forms

GravityExtra
How to Add a Video and Link Preview Field to Gravity Forms

Sooner or later a form needs a link. A portfolio form asks for a video reel, a music contest asks for a track, a job form asks for a work sample, a press form asks for the article that mentions you. A plain text box takes the link, but you never know whether it works until you click it, and you cannot see what it is until you leave your inbox. In this tutorial we build a form with a live preview for pasted links in Gravity Forms with the Embed and URL Preview add-on, and look at the privacy and safety choices that matter when a visitor can paste any address.

A Share your link form with a name field and an Embed field that holds a pasted video link, and under it a preview card with the video title, the line Nothing is loaded from YouTube until you click and a Load embed button
The visitor sees the title at once; the video loads only after the click.

Why a Link Field Needs More Than a Text Box

A link in a text box is only a string. The visitor does not know whether they pasted the right one, and you do not know what it points to. A preview closes that gap. The visitor sees the title of the video right under the field, so they notice at once when they copied the wrong tab. You see the same title and the embedded player in the entry, so you can judge a submission without opening ten tabs.

There is a second reason, and it is control. If you only want YouTube links, or only links from a music service, a plain field cannot check that. The field in this tutorial can: you tick the providers you accept, and you can require one of them.

Step 1: Add the Field

Open your form and add Embed / URL Preview from the Advanced Fields group. Give it a label and a placeholder that tells people what to paste, for example Paste a link to your video. The field panel shows a checkbox for every provider the add-on knows: YouTube, Vimeo, SoundCloud, Spotify, TikTok, X and Instagram, plus one box for any other provider that WordPress oEmbed supports and one for the generic link card.

Step 2: Decide What You Accept

Think about the question you are asking. For a video reel, tick YouTube and Vimeo. For a music contest, tick SoundCloud and Spotify. For a press form, tick the link card, because an article can live on any site. If you need exactly one provider, pick it in the select Only accept links from, and everything else is refused with a clear message, such as Please paste a link from YouTube.

The check happens twice: live under the field while the visitor types, and again on the server when the form is submitted. A visitor who edits the page in the browser to get around the live message still meets the server check.

Step 3: Leave Click to Load On

This is the privacy setting, and it is on by default for a reason. When a web page shows an embedded video, the visitor’s browser contacts the video provider at once. The provider learns the visitor’s address and can set its own cookies. In many countries that needs consent, and a form that only asks for a link should not need a consent banner of its own.

With click to load, the form shows a card with the title and a button. The title comes from your own server, so no request leaves for the provider. The note under the button says so: nothing is loaded from the provider until you click. When the visitor presses the button the player appears. If your visitors are all people you already have consent from, or if you prefer a smoother look, switch the option off in the field.

How the Preview Is Made

The visitor never talks to the provider. The browser asks a route on your own site, and your server does the rest. That route is protected: it needs a nonce made for this form and this field, the license must be active, the field must accept the link, and a visitor who asks for too many previews in five minutes is asked to wait.

For links of a provider, your server uses WordPress core oEmbed. That is the same mechanism that turns a pasted video address into a player in the block editor, and it knows a long list of providers. The add-on asks the endpoint of the provider for the title, the author and the player. It turns the answer into a clean, sandboxed iframe and throws away everything else the provider sent, including scripts and event handlers. If a provider only offers a script, as many social networks do, the form shows a card with the text of the post instead of loading the script.

For any other page, the server reads the head of the page and takes the title, the description and the picture that the page offers for sharing. Reading a page that a stranger chose is the risky part, so it has its own guard, described below.

The same form with a pasted web page: a link card with the page title, a short description, the site name and a Show picture button
Any page can become a link card, with the picture loaded on request.

The Safety Net: Private Addresses Are Off Limits

Imagine a visitor who pastes the address of a service inside your hosting network, or the address that cloud servers use to hand out their own credentials. If your server fetched it and showed the answer, you would have given a stranger a way to look inside your network. This kind of attack has a name, server-side request forgery, and a link preview is a textbook place for it.

The add-on closes the door in several layers. It accepts only http and https on the normal ports. It refuses names like localhost and addresses written as one big number or in hex. It looks the name up and requires every address it resolves to to be a public one, so the private ranges, the loopback addresses, the cloud metadata range and the IPv6 forms that hide an IPv4 address are all refused. It then pins the request to the address it checked, so the answer cannot change between the check and the call. It follows redirects by hand, at most three, and checks every step again, so a harmless page that redirects to an inside address goes nowhere. Finally it reads at most 256 KB and waits at most five seconds.

A pasted address that points inside is refused right under the field as not a valid web address, and even if one slipped past, the fetch itself would be refused.

What You Get in the Entry

The entry keeps the link as its value, which means searching, filtering and exporting work on the link, exactly as with a text field. Next to it the add-on saves the title, the provider and the embed data. Open the entry and you see the player with the title and the link, or a card for an ordinary page.

A Gravity Forms entry in the admin that shows the embedded video player, its title and the link
The entry shows the embed, cleaned and sandboxed.

The iframe is rebuilt from clean data every time the entry is shown, and it passes through wp_kses, which keeps an iframe with a short list of attributes and nothing else. Even if somebody changed the saved data, no script and no event handler would reach your admin screen.

Put the Link and the Title in Your Notification

An e-mail cannot show a player, so a notification shows the title in bold and the link under it. For your own layout use the merge tags. Replace the label and the id with those of your field.

<p>New link from {Your name:1}</p>
<p>Link: {Embed:2:url}</p>
<p>Title: {Embed:2:title}</p>
<p>Provider: {Embed:2:provider}</p>
<p>{Embed:2:link}</p>

The tag without a modifier and the url modifier give the link. The title modifier gives the title, provider gives the name of the provider, and link gives the title as a link. Because the title is read from the saved entry, it also works when Gravity Forms sends the notification in the background.

Forms That Are Not Simple

Real forms are rarely one page. The field copes with the cases that usually break scripts. On an AJAX form the preview starts again after a validation message. On a multi-page form the link is kept when the visitor goes back and forth, and the preview returns with it. With save and continue, the link is restored from the saved form and the preview loads again. If conditional logic hides the field, nothing is saved for it.

Tips for Better Link Forms

  • Ask for one thing. A form that asks for a video link should say so in the label and the placeholder.
  • Tick only the providers you really accept. Every extra provider is one more kind of link to look at.
  • Keep click to load on unless you have a reason to switch it off.
  • Use the title in your notification subject line through the merge tag, so you can tell submissions apart in your inbox.
  • Raise the rate limit only if you expect many visitors behind one shared address, such as a school or an office.
  • Test with a real phone. The card and the player scale with the screen, but it is nice to see.

What About Hosting?

The preview is made on your server, so PHP must be allowed to make outgoing web requests. Almost every host allows it. A few block it; if previews never appear, ask your host. Nothing else is needed: no key, no outside account and no extra service.

Frequently Asked Questions

Does it work with providers that are not on the list?

Yes. Tick the box for other WordPress oEmbed providers and every provider that WordPress knows works. Any page can also be shown as a link card.

Does it send links to a GravityExtra server?

No. Your own server asks the provider, or reads the page itself.

Can a visitor make my site show something harmful?

No. Only a sandboxed iframe rebuilt from clean data is ever shown, and only in the entry. Texts are stripped of markup and pictures must be web addresses.

What if a page cannot be read?

The visitor sees a short note that no preview is available, and the link is still saved.

A good link field tells the visitor what they pasted and tells you what you received. With a preview, a provider choice and the privacy switch on, it does both without leaving Gravity Forms and without sending your visitors anywhere before they click.

Paste a link, see the preview

A live preview for videos, songs, posts and pages, with click to load for privacy and the embed saved in every entry.

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr