PHP code example of ekumanov / flarum-ext-inline-audio
1. Go to this page and download the library: Download ekumanov/flarum-ext-inline-audio 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/ */
ekumanov / flarum-ext-inline-audio example snippets
use FoF\Upload\Contracts\Template;
use FoF\Upload\File;
use Flarum\Foundation\AbstractServiceProvider;
use FoF\Upload\Helpers\Util;
class FilenameLink implements Template
{
public function tag(): string { return 'filenamelink'; }
public function name(): string { return 'Filename link'; }
public function description(): string { return 'Generates a link with the filename as text'; }
// fof/upload 2.0.0-beta.7+ declares this optional $displayName parameter
// on the interface. Omitting it is a fatal error for every PHP process
// that boots Flarum (queue worker, scheduler, console), so keep it.
public function preview(File $file, ?string $displayName = null): string
{
$label = trim(preg_replace('/\s+/u', ' ', (string) $displayName));
return '[' . ($label !== '' ? $label : $file->base_name) . '](' . $file->url . ')';
}
}
class FilenameLinkServiceProvider extends AbstractServiceProvider
{
public function register()
{
$this->container->make(Util::class)
->addRenderTemplate($this->container->make(FilenameLink::class));
}
}
// In your return array:
(new Extend\ServiceProvider())->register(FilenameLinkServiceProvider::class),