You are here

function entity_embed_ckeditor_plugin in Entity Embed 7.2

Same name and namespace in other branches
  1. 7 entity_embed.ckeditor.inc \entity_embed_ckeditor_plugin()

Implements hook_ckeditor_plugin().

File

./entity_embed.ckeditor.inc, line 11
CKEditor integration for the entity_embed module.

Code

function entity_embed_ckeditor_plugin() {
  $plugins = array(
    'drupalentity' => array(
      'name' => 'drupalentity',
      'desc' => t('Plugin for embedding entities'),
      'path' => base_path() . drupal_get_path('module', 'entity_embed') . '/js/plugins/drupalentity/',
      'default' => 'f',
    ),
  );

  // Add user-defined buttons.
  $embed_buttons = entity_embed_embed_button_load_all();
  $buttons = array();
  foreach ($embed_buttons as $embed_button) {
    $icon = 'entity.png';
    $icon_path = FALSE;

    // Use a custom icon when available.
    if ($fid = $embed_button->button_icon_fid) {
      if ($file = file_load($fid)) {

        // We are unable to use _entity_embed_button_image() because CKEditor
        // requires a specific format for icon paths.
        if ($wrapper = file_stream_wrapper_get_instance_by_uri($file->uri)) {
          $icon = file_uri_target($file->uri);
          $icon_path = base_path() . $wrapper
            ->getDirectoryPath() . '/';
        }
      }
    }
    $buttons[$embed_button->name] = array(
      'label' => check_plain($embed_button->button_label),
      'icon' => $icon,
      'icon_path' => $icon_path,
    );
  }
  $plugins['drupalentity']['buttons'] = $buttons;
  return $plugins;
}