Download the PHP package nathancox/embedfield without Composer
On this page you can find all versions of the php package nathancox/embedfield. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nathancox/embedfield
More information about nathancox/embedfield
Files in nathancox/embedfield
Package embedfield
Short Description A form field for adding oembed objects (primarily videos) to pages or dataobjects
License BSD-3-Clause
Homepage https://github.com/nathancox/silverstripe-embedfield
Informations about the package embedfield
SilverStripe EmbedField
This field is designed to let users attached an oembed object (eg a YouTube video) to a page or dataobject. It stores the oembed result information in an EmbedObject for easy access from the template (or wherever you want it).
Work in progress.
Requirements
- SilverStripe 4.11+ or 5.x
Documentation
Installation Instructions
- Install with composer
composer require nathancox/embedfield
- Visit yoursite.com/dev/build to rebuild the database
Usage Overview
Make a has_one relationship to an EmbedObject then create an EmbedField in getCMSFields:
Gives us:
In the page template the video can now be embedded with $MyVideo
.
Each embed type is rendered with it's own template (eg EmbedObject_video.ss and EmbedObject_photo.ss). The default templates just return the markup generated by SilverStripe's OembedResult::forTemplate(). You can override them in your theme:
themes/mytheme/templates/nathancox/EmbedField/Model/EmbedObject_video.ss:
This can be combined with your own CSS to make aspect ratio aware flexible video (see http://alistapart.com/article/creating-intrinsic-ratios-for-video).