Provide a hook that allows other modules to alter the output of scald library items.

Use case: we needed to implement default contexts on a per atom type basis. When you drag and drop an atom from the dnd library onto a scald enabled CKEditor field, the atom will already be rendered with the system wide default context 'sdl_editor_representation'. Therefore it seemed the cleanest way to hook into the process where a scald library item gets rendered like this:

function scald_contexts_scald_dnd_library_item_alter($atom, &$item) {
  // Use a default context if one has been configured for the given atom type
  if ($type_context = variable_get('scald_default_context_' . $atom->type, NULL)) {
    $item['editor'] = scald_render($atom, $type_context);
  }
}
CommentFileSizeAuthor
#1 scald-library_item_alter-2126295-1.patch1.16 KBal.ex

Comments

al.ex’s picture

StatusFileSize
new1.16 KB
al.ex’s picture

Title: Introduce hook to alter an scald library item » Introduce hook to alter a scald library item
jcisio’s picture

Status: Needs review » Fixed

Thanks. Committed b929d3e.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.