Skip to content

Instantly share code, notes, and snippets.

@cesarmiquel
Created January 27, 2013 05:36
Show Gist options
  • Select an option

  • Save cesarmiquel/4646624 to your computer and use it in GitHub Desktop.

Select an option

Save cesarmiquel/4646624 to your computer and use it in GitHub Desktop.
This simple Drupal module renders a URL with the flowplayer (http://flowplayer.org/) Javscript library. It requires having the Drupal flowplayer module.
<?php
/**
* Implements hook_field_formatter_info().
*/
function edl_flowplayer_field_formatter_info() {
return array(
// the key must be unique, so it's best to prefix with your module's name.
'edl_flowplayer_flowplayer' => array(
// the label is is what is displayed in the select box in the UI.
'label' => t('Render URL with flowplayer'),
// field types is the important bit!! List the field types your formatter is for.
'field types' => array('text', 'link_field'),
// You can usually leave 'multiple values' as follows:
'multiple values' => FIELD_BEHAVIOR_DEFAULT,
),
);
}
/**
* Implements hook_field_formatter_view(). This code just passes straight
* through to a theme function, edl_flowplayer_formatter_FORMATTER
* (e.g. edl_flowplayer_formatter_edl_flowplayer_absolute_url).
*/
function edl_flowplayer_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$elements = array();
foreach ($items as $delta => $item) {
$video = theme('flowplayer', array(
'config' => array(
'clip' => array(
'url' => $item['value'],
'autoPlay' => FALSE, // Turn autoplay off
)
),
));
$elements[$delta] = array(
'#markup' => $video,
);
}
return $elements;
}
// vim: se ft=php ts=2 sw=2 expandtab:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment