Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hi
I'm creating a Vzaar provider module for Video Embed Field d8. The code looks like this, and seems to work well:
<?php
namespace Drupal\video_embed_vzaar\Plugin\video_embed_field\Provider;
use Drupal\video_embed_field\ProviderPluginBase;
/**
* A Vzaar provider plugin for video embed field.
*
* @VideoEmbedProvider(
* id = "vzaar",
* title = @Translation("Vzaar")
* )
*/
class Vzaar extends ProviderPluginBase {
/**
* {@inheritdoc}
*/
public function renderEmbedCode($width, $height, $autoplay) {
$iframe = [
'#type' => 'video_embed_iframe',
'#provider' => 'vzaar',
'#url' => sprintf('https://view.vzaar.com/%s/player', $this->getVideoId()),
'#query' => [],
'#attributes' => [
'width' => $width,
'height' => $height,
'frameborder' => '0',
'allowfullscreen' => 'allowfullscreen',
],
];
return $iframe;
}
/**
* {@inheritdoc}
*/
public function getRemoteThumbnailUrl() {
$url = 'https://view.vzaar.com/%s/thumb';
return sprintf($url, $this->getVideoId());
}
/**
* {@inheritdoc}
*/
public static function getIdFromInput($input) {
if (strpos($input, 'view.vzaar.com') !== false) {
// e.g. https://view.vzaar.com/848450
$id= preg_replace('/[^0-9]/','',$input);
return isset($id) ? $id : false;
}
return false;
}
}
I would like to additionally add a download link below the embedded video player. This would simple be:
<a href="https://view.vzaar.com/848450/download">Download</a>
Could you advise how I could achieve this please?
Comments
Comment #2
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedI would write a new field formatter for this and place the extra download link in there.
Comment #3
Sam152 CreditAttribution: Sam152 as a volunteer and at PreviousNext commentedWith the advent of Media in core, the Video Embed Field module has moved to being minimally maintained. Only issues which assist in the migration to Media in core will be committed. To read more about this decision, please see: #3089599: Maintenance status for Video Embed Field now that media is in core.