FieldtypeOembed by Neue Rituale

Collect and store oEmbed data

FieldtypeOembed

What it does


Store, collect and update oembed data from external sources. It used the great PHP Library Essence by Félix Girault and adds some processwire magic. This field is based on the example module FieldtypeEvents by Ryan and the TextformatterOEmbed by felixwahner. Thanks!

Features


  • Simple embedding of content via oembed endpoints and opengraph crawling
  • Backend preview
  • Searching in oembed data with $pages->find()
  • Autoupdate with lazycron
  • Support for ProcessGraphQL with the additional module GraphQLFieldtypeOembed

Install


  1. Copy the files for this module to /site/modules/FieldtypeOembed/
  2. Execute the following command in the /site/modules/FieldtypeOembed/ directory.
    composer install
  3. In admin: Modules > Refresh. Install Fieldtype > Oembed.
  4. Create a new field of type Oembed, and name it whatever you would like. In our examples we named it simply "embed".
  5. Add the field to a template and edit a page using that template.

Configuration


Modules > Configure > FieldtypeOembed

Lazycron

Setup the Lazycron schedule. The cache expiration is configurable in the field settings.

Lazycron

Custom Provider for Essence

You can configure your own Oembed or OpenGraph providers for Essence.
How to add custom providers (Essence Git)

{
   "getty": {
      "class": "OEmbed",
      "filter": "~gty\\.im/.+~i",
      "endpoint": "http://embed.gettyimages.com/oembed?url=:url"
   },
   "neuerituale": {
      "class": "OpenGraph",
      "filter": "~neuerituale\\.com.?~i"
   },
   "tiktok": {
      "class": "OEmbed",
      "filter": "~tiktok\\.com/.+~i",
      "endpoint": "https://www.tiktok.com/oembed?url=:url"
   },
   "InstagramOEmbed": {
      "class": "OEmbed",
      "filter": "~instagr(\\.am|am\\.com)/p/.+~i",
      "endpoint": "http://api.instagram.com/oembed?format=json&url=:url&hidecaption=true"
   },
}
You can disable all providers
{
	"23hq": false,
	"500px": false,
	"Animoto": false,
	"Aol": false,
	"App.net": false,
	"Bambuser": false,
	"Bandcamp": false,
	"Blip.tv": false,
	"Cacoo": false,
	"CanalPlus": false,
	"Chirb.it": false,
	"CircuitLab": false,
	"Clikthrough": false,
	"CollegeHumorOEmbed": false,
	"CollegeHumorOpenGraph": false,
	"Coub": false,
	"CrowdRanking": false,
	"DailyMile": false,
	"Dailymotion": false,
	"Deviantart": false,
	"Dipity": false,
	"Documentcloud": false,
	"Dotsub": false,
	"EdocrOEmbed": false,
	"EdocrTwitterCards": false,
	"FacebookPost": false,
	"FlickrOEmbed": false,
	"FlickrOpenGraph": false,
	"FunnyOrDie": false,
	"Gist": false,
	"Gmep": false,
	"HowCast": false,
	"Huffduffer": false,
	"Hulu": false,
	"Ifixit": false,
	"Ifttt": false,
	"Imgur": false,
	"InstagramOEmbed": false,
	"InstagramOpenGraph": false,
	"Jest": false,
	"Justin": false,
	"Kickstarter": false,
	"Meetup": false,
	"Mixcloud": false,
	"Mobypicture": false,
	"Nfb": false,
	"Official.fm": false,
	"Polldaddy": false,
	"PollEverywhere": false,
	"Prezi": false,
	"Qik": false,
	"Rdio": false,
	"Revision3": false,
	"Roomshare": false,
	"Sapo": false,
	"Screenr": false,
	"Scribd": false,
	"Shoudio": false,
	"Sketchfab": false,
	"SlideShare": false,
	"SoundCloud": false,
	"SpeakerDeck": false,
	"Spotify": false,
	"TedOEmbed": false,
	"TedOpenGraph": false,
	"Twitter": false,
	"Ustream": false,
	"Vhx": false,
	"Viddler": false,
	"Videojug": false,
	"Vimeo": false,
	"Vine": false,
	"Wistia": false,
	"WordPress": false,
	"Yfrog": false,
	"Youtube": false,
	"FacebookVideo": false
}

Field settings

Fields > embed > Details The FieldtypeOembed extends the FieldtypeURL (core). In addition to these settings, you can also set the cache time for the oembed data. The lazycron will update the data.

Fieldsettings

Field preview

Fieldpreview

API


Returns the Oembed object (WireData).

/** @var \ProcessWire\Oembed */
$page->embed

Check emptiness

/** @var boolean **/
$page->embed->empty

Render

/** @var string return the html from oembed result */
"$page->embed"
$page->embed->html

The Oembed object


// print_r($page->embed);

ProcessWire\Oembed Object
(
    [data] => Array
        (
            [empty] => false
            [url] => http://www.youtube.com/watch?v=dQw4w9WgXcQ
            [html] => '...'
            [type] => video
            [title] => Rick Astley - Never Gonna Give You Up (Video)
            [width] => 200
            [height] => 113
            [version] => 1.0
            [authorUrl] => https://www.youtube.com/user/RickAstleyVEVO
            [authorName] => RickAstleyVEVO
            [providerUrl] => https://www.youtube.com/
            [providerName] => YouTube
            [thumbnailUrl] => https://i.ytimg.com/vi/dQw4w9WgXcQ/hqdefault.jpg
            [thumbnailWidth] => 480
            [thumbnailHeight] => 360
        )
)

Find pages


You can query the oembed result fields

$pages->find('embed.providerName=YouTube');
$pages->find('embed.width>=200');

GraphQLFieldtypeOembed


You can query this field over ProcessGraphQL.
Please install the additional module GraphQLFieldtypeOembed.

Field definitions

myfield {
   empty: Boolean
   title: String
   authorName: String
   authorUrl: String
   type: String
   height: Int
   width: Int
   providerName: String
   providerUrl: String
   thumbnailHeight: Int
   thumbnailWidth: Int
   thumbnailUrl: String
   html: String
   url: String
}

Todos


  • Remove extend urlfield!
  • remove _oembed helper construct (dirty)

Install and use modules at your own risk. Always have a site and database backup before installing new modules.

Twitter updates

  • ProcessWire 3.0.210 new main/master version released— More
    6 January 2023
  • ProcessWire 3.0.209: Core updates and an interesting AI that knows ProcessWire– More
    30 December 2022
  • Implementing and using TinyMCE 6 in ProcessWire– More
    16 December 2022

Latest news

  • ProcessWire Weekly #454
    In the 454th issue of ProcessWire Weekly we'll introduce a couple of brand new third party modules, check out what's new in the latest dev version of ProcessWire (3.0.211), and more. Read on!
    Weekly.pw / 21 January 2023
  • ProcessWire 3.0.210 new main/master version
    140 commits, 55 resolved issues, dozens of new features, eight contributors, and five new pull requests make yet another great new version of ProcessWire.
    Blog / 6 January 2023
  • Subscribe to weekly ProcessWire news

“Yesterday I sent the client a short documentation for their ProcessWire-powered website. Today all features already used with no questions. #cmsdoneright—Marc Hinse, Web designer/developer