1. Go to this page and download the library: Download nr/fieldtypeoembed library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nr / fieldtypeoembed example snippets
/** @var \ProcessWire\Oembed */
$page->embed
/** @var boolean **/
$page->embed->empty
/** @var string return the html from oembed result */
"$page->embed"
$page->embed->html
// some where in your ready.php
// Replace hqdefault preview thumbnail with maxresdefault
$this->addHook('FieldtypeOembed::filterProps', function (HookEvent $event) {
$propsArray = $event->arguments(0);
if(is_array($propsArray) && $propsArray['providerName'] === 'YouTube') {
$maxResultUrl = str_replace('/hqdefault.jpg', '/maxresdefault.jpg', $propsArray['thumbnailUrl']);
// test max result url
if((new WireHttp())->status($maxResultUrl) === 200) $propsArray['thumbnailUrl'] = $maxResultUrl;
$event->return = $propsArray;
}
});