mirror of
https://github.com/a2nt/cms-niceties.git
synced 2024-10-22 11:05:46 +02:00
IMPR: Vimeo video options, optional loading assets with absolute URL
This commit is contained in:
parent
afb39c8b22
commit
347c389447
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace A2nt\CMSNiceties\Extensions;
|
||||
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
@ -42,41 +41,41 @@ class EmbeddedObjectExtension extends DataExtension
|
||||
$matches
|
||||
);
|
||||
if (isset($matches[1])) {
|
||||
$videoID = $matches[1];
|
||||
$videoID = $matches[1];
|
||||
|
||||
$params = array_merge($params, [
|
||||
'feature=oembed',
|
||||
'wmode=transparent',
|
||||
'enablejsapi=1',
|
||||
'disablekb=1',
|
||||
'iv_load_policy=3',
|
||||
'modestbranding=1',
|
||||
'rel=0',
|
||||
'showinfo=0',
|
||||
//'controls='.($this->owner->getField('Controls') ? '1': '0')
|
||||
]);
|
||||
$params = array_merge($params, [
|
||||
'feature=oembed',
|
||||
'wmode=transparent',
|
||||
'enablejsapi=1',
|
||||
'disablekb=1',
|
||||
'iv_load_policy=3',
|
||||
'modestbranding=1',
|
||||
'rel=0',
|
||||
'showinfo=0',
|
||||
//'controls='.($this->owner->getField('Controls') ? '1': '0')
|
||||
]);
|
||||
|
||||
if ($this->owner->getField('Autoplay')) {
|
||||
$params[] = 'autoplay=1';
|
||||
$params[] = 'mute=1';
|
||||
}
|
||||
if ($this->owner->getField('Autoplay')) {
|
||||
$params[] = 'autoplay=1';
|
||||
$params[] = 'mute=1';
|
||||
}
|
||||
|
||||
if ($this->owner->getField('Loop')) {
|
||||
$params[] = 'loop=1';
|
||||
$params[] = 'playlist=' . $videoID;
|
||||
}
|
||||
if ($this->owner->getField('Loop')) {
|
||||
$params[] = 'loop=1';
|
||||
$params[] = 'playlist=' . $videoID;
|
||||
}
|
||||
|
||||
$this->owner->EmbedHTML = preg_replace(
|
||||
'/src="([A-z0-9:\/\.]+)\??(.*?)"/',
|
||||
'src="https://www.youtube.com/embed/' . $videoID . '?' . implode('&', $params) . '" '
|
||||
. implode(' ', $iframe_params),
|
||||
$this->owner->EmbedHTML
|
||||
);
|
||||
$this->owner->EmbedHTML = preg_replace(
|
||||
'/src="([A-z0-9:\/\.]+)\??(.*?)"/',
|
||||
'src="https://www.youtube.com/embed/' . $videoID . '?' . implode('&', $params) . '" '
|
||||
. implode(' ', $iframe_params),
|
||||
$this->owner->EmbedHTML
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (stripos($this->owner->EmbedHTML, 'https://player.vimeo.com/video/') > 0) {
|
||||
$url = $this->owner->getField('SourceURL');
|
||||
$url = $this->owner->getField('SourceURL');
|
||||
preg_match(
|
||||
'/^https:\/\/vimeo\.com\/([A-z0-9]+)/',
|
||||
$url,
|
||||
@ -84,10 +83,9 @@ class EmbeddedObjectExtension extends DataExtension
|
||||
);
|
||||
$videoID = $matches[1];
|
||||
|
||||
$params = array_merge($params, [
|
||||
'controls='.($this->owner->getField('Controls') ? '1': '0'),
|
||||
'background=1',
|
||||
]);
|
||||
/*$params = array_merge($params, [
|
||||
'controls='.($this->owner->getField('Controls') ? '1' : '0'),
|
||||
]);*/
|
||||
|
||||
if ($this->owner->getField('Autoplay')) {
|
||||
$params[] = 'autoplay=1';
|
||||
|
@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
/** @noinspection PhpUnusedPrivateFieldInspection */
|
||||
|
||||
/**
|
||||
@ -32,6 +33,7 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
|
||||
*/
|
||||
private static $dist = 'client/dist';
|
||||
private static $webp = false;
|
||||
private static $absolute_path = false;
|
||||
|
||||
/**
|
||||
* @return array
|
||||
@ -135,15 +137,23 @@ class WebpackTemplateProvider implements TemplateGlobalProvider
|
||||
public static function toPublicPath($path): string
|
||||
{
|
||||
$cfg = self::config();
|
||||
return strpos($path, '//') === false ?
|
||||
Controller::join_links(
|
||||
RESOURCES_DIR,
|
||||
self::projectName(),
|
||||
$cfg['dist'],
|
||||
(strpos($path, '.css') ? 'css' : 'js'),
|
||||
$path
|
||||
)
|
||||
: $path;
|
||||
if (strpos($path, '//')) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
$link = Controller::join_links(
|
||||
RESOURCES_DIR,
|
||||
self::projectName(),
|
||||
$cfg['dist'],
|
||||
(strpos($path, '.css') ? 'css' : 'js'),
|
||||
$path
|
||||
);
|
||||
|
||||
if ($cfg['absolute_path']) {
|
||||
$link = Director::absoluteURL($link);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
public static function config(): array
|
||||
|
Loading…
Reference in New Issue
Block a user