Asset

The Asset module proposes a new approach to the media management in Drupal, resolving a long-standing problem of reusable media files (images, videos, documents, etc) that evolved into the problem of reusable media content (images/videos/documents/etc with the attached content like description/licence/etc).

Ooyala

The Ooyala module allows for your site to be integrated with the Ooyala video hosting service. Current functionality includes:

The Atom reference module

Introduction

The atom reference modules provides a field where atoms can be drag and dropped from the library. This allows the user to make a reference from any entity where the field has been inserted to an atom or a list of atoms. This can per example be used to create a media gallery.

PHP

Core hooks used

hook_field_info() :
Define the field information see api documentation.

hook_field_instance_settings_form() :
Field properties for the form when the field is added to an entity. See api documentation.

hook_field_schema() :
Defines the field database column. We use only one, the atom sid. Please see hook field schema

hook_field_validate() :
We check that the referenced atoms type is in the list of type that is allowed for the field.api documentation

hook_field_is_empty() :

The Mee Module

Introduction

The Mee Module is the module transforming a standard textarea field into a scald enabled drag and droppable field. It also generates the resource manager located under the field.
This resource manager allows the user to order the dragged elements into primary and secondary resource. This can be useful to build a view showing which media are in which entities, or to use a cron to unpublish an entity when a primary resource is no more licenced.
We will look below into the code to demonstrate how it's built.

Php

Core hooks used

hook_field_info_alter() :
We add default values in the settings of instance :

$info['text_with_summary']['instance_settings']['dnd_enabled'] = 0;

hook_form_alter() :
We add three settings for the textarea field :
dnd_enabled > We enable the drag and drop capabilities
mee_enabled > add the resource manager below the field
context > Choose the scald representation to be used when a element will be dropped in the textarea

Hooks on behalf of the text module

hook_field_presave()
Before storing in the database the content of the field, we transform the content of the Scald atom to the SAS version
hook_field_insert()
We extract the Atom Id's used in the field and we store them in the mee_resource table :

The drag and drop and library module

Introduction

The Drag and Drop (dnd) module is responsible for the Scald UX. It is a generic module to create the drag and drop experience between a library and target fields. Library module must have a specified interface (see below), contains an atom list, a list of quick atom add buttons and provides search capabilities in the atoms list.

The DnD Library (scald_dnd_library) module is a built-in library to use with the DnD module. This library is mostly a view on the atoms with exposed filters to make the search. Thus it is customisable as a standard view in Views UI.

Drag and Drop module

Each dropped atom contain 2 parts:

- The "editor" part: is the rendered atom itself. The default library (scald_dnd_library) uses sdl_editor_representation context to render it. This part should generally not be modified, it could be in HTML format, or the token-like SAS (Scald Atom Shorthand) format and it is updated automatically.

- The "legend" part: usually is the atom title and atom author. You can modify, or even delete, text in this part. A provider can omit this part by setting
$atom->omit_legend = TRUE.

PHP part

Permission

The modules add on permission which is 'Administer DnD'.

Theme

We have one hook_theme implementation that will fire the dnd_library_wrapper function.

Creating a Scald Provider

List of Providers hooks defined by Scald

// Provider Hooks
function hook_scald_atom_providers();
function hook_scald_add_form(&$form, &$form_state) ;
function hook_scald_add_form_fill(&$atom, $form, $form_state);
function hook_scald_fetch($atom, $type);
function hook_scald_prerender($atom, $context, $options, $mode);

Example implementation of the hooks for a provider

The example used here is the Scald Twitter provider.

scald_twitter.install

  • In the hook_install of our module, we will declare a new media type, which will create a new pre-configured entity bundle.
function scald_twitter_install() {
 scald_add_type('twitter', 'Twitter', 'Resource twitter');
}

scald_twitter.module

  • First the module needs to be registered as one that will provides Atoms for Scald. It'll provide atoms of the 'twitter' type that was defined in the .install.
/**
 * Implements hook_scald_atom_providers.
 * Tell Scald that we'll be providing some twitter atoms.
 */
function scald_twitter_scald_atom_providers() {
  return array(
    'twitter' => 'Tweets hosted on twitter'
  );
}
  • This is the form that will appear when you click on the Twitter icon in the library, Or when you click on 'Add Atom' menu and choose twitter.

<?php

Pages

Subscribe with RSS Subscribe to RSS - media assets