安装fof/formatting
composer require fof/formatting
并在/vendor/fof/formatting/src/Listeners/FormatterConfigurator.php
末尾添加如下内容
具体在哪里找到的方法我忘记了,等找到出处我再过来添加
/**
* Adds settings to admin settings.
*
* @param Serializing $event
*/public function addData(Serializing $event)
{
if ($event->isSerializer(ForumSerializer::class) && $event->actor->isAdmin()) {
$event->attributes['fof-formatting.plugins'] = $this->plugins;
}
}
public function configureFormatter(Configuring $event)
{
foreach ($this->plugins as $plugin) {
$enabled = $this->settings->get('fof-formatting.plugin.'.strtolower($plugin));
if ($enabled) {
if ($plugin == 'MediaEmbed') {
//www.music163.com
$event->configurator->MediaEmbed->add(
'music163',
[
'host' => 'music.163.com',
'extract' => "!music\\.163\\.com/outchain/player\\?type=(?'type'\\d+)&id=(?'id'\\d+)&auto=(?'auto'\\d+)&height=(?'height'\\d+)!",
'iframe' => [
'width' => "100%",
'height' => 430,
'src' => '//music.163.com/outchain/player?type={@type}&id={@id}&auto={@auto}&height={@height}'
]
]
);
//www.bilibili.com
$event->configurator->MediaEmbed->add(
'bilibili',
[
'host' => 'www.bilibili.com',
'extract' => [
"!www.bilibili.com/video/av(?'id'\\d+)!",
"!www.bilibili.com/video/av(?'id'\\d+)\\?p=(?'pid'\\w+)!"
],
'iframe' => [
'width' => 800,
'height' => 500,
'src' => '//player.bilibili.com/player.html?aid={@id}&page={@pid}'
]
]
);
//v.qq.com
$event->configurator->MediaEmbed->add(
'qq',
[
'host' => 'qq.com',
'extract' => [
"!qq\\.com/x/cover/\\w+/(?'id'\\w+)\\.html!",
"!qq\\.com/x/cover/\\w+\\.html\\?vid=(?'id'\\w+)!",
"!qq\\.com/cover/[^/]+/\\w+/(?'id'\\w+)\\.html!",
"!qq\\.com/cover/[^/]+/\\w+\\.html\\?vid=(?'id'\\w+)!",
"!qq\\.com/x/page/(?'id'\\w+)\\.html!",
"!qq\\.com/page/[^/]+/[^/]+/[^/]+/(?'id'\\w+)\\.html!"
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => '//v.qq.com/iframe/player.html?vid={@id}&tiny=0&auto=0'
]
]
);
//www.huya.com
$event->configurator->MediaEmbed->add(
'huya',
[
'host' => 'v.huya.com',
'extract' => [
"!huya\\.com/play/(?'id'\\d+)\\.html!",
],
'flash' => [
'width' => 760,
'height' => 450,
'src' => 'https://vhuya-static.huya.com/video/vppp.swf?&auto_play=0&vid={@id}'
]
]
);
//www.douyu.com
$event->configurator->MediaEmbed->add(
'douyu',
[
'host' => 'v.douyu.com',
'extract' => [
"!douyu\\.com/show/(?'id'\\w+)!",
],
'iframe' => [
'width' => 760,
'height' => 450,
'src' => 'https://v.douyu.com/video/share/index?vid={@id}'
]
]
);
//www.missevan.com
$event->configurator->MediaEmbed->add(
'missevan',
[
'host' => 'www.missevan.com',
'extract' => [
"!missevan\\.com/albumiframe/(?'id'\\d+)!",
],
'iframe' => [
'width' => 720,
'height' => 450,
'src' => 'https://www.missevan.com/albumiframe/{@id}?autoplay=false&playlist=true'
]
]
);
(new MediaPack())->configure($event->configurator);
} else {
$event->configurator->$plugin;
}
}
}
}