root / drupal7 / sites / all / modules / media / modules / media_wysiwyg / media_wysiwyg.api.php @ ca0757b9
1 | ca0757b9 | Assos Assos | <?php
|
---|---|---|---|
2 | |||
3 | /**
|
||
4 | * @file
|
||
5 | * Hooks provided by the Media WYSIWYG module.
|
||
6 | */
|
||
7 | |||
8 | /**
|
||
9 | * Alter a list of view modes allowed for a file embedded in the WYSIWYG.
|
||
10 | *
|
||
11 | * @param array $view_modes
|
||
12 | * An array of view modes that can be used on the file when embedded in the
|
||
13 | * WYSIWYG.
|
||
14 | * @param object $file
|
||
15 | * A file entity.
|
||
16 | *
|
||
17 | * @see media_get_wysiwyg_allowed_view_modes()
|
||
18 | */
|
||
19 | function hook_media_wysiwyg_wysiwyg_allowed_view_modes_alter(&$view_modes, $file) { |
||
20 | $view_modes['default']['label'] = t('Display an unmodified version of the file'); |
||
21 | unset($view_modes['preview']); |
||
22 | } |
||
23 | |||
24 | /**
|
||
25 | * Alter the WYSIWYG view mode selection form.
|
||
26 | *
|
||
27 | * Similar to a form_alter, but runs first so that modules can add
|
||
28 | * fields specific to a given file type (like alt tags on images) before alters
|
||
29 | * begin to work on the fields.
|
||
30 | *
|
||
31 | * @param array $form
|
||
32 | * An associative array containing the structure of the form.
|
||
33 | * @param array $form_state
|
||
34 | * An associative array containing the current state of the form.
|
||
35 | * @param object $file
|
||
36 | * A file entity.
|
||
37 | *
|
||
38 | * @see media_format_form()
|
||
39 | */
|
||
40 | function hook_media_wysiwyg_format_form_prepare_alter(&$form, &$form_state, $file) { |
||
41 | $form['preview']['#access'] = FALSE; |
||
42 | |||
43 | $file = $form_state['file']; |
||
44 | $form['heading']['#markup'] = t('Embedding %filename of type %filetype', array('%filename' => $file->filename, '%filetype' => $file->type)); |
||
45 | } |
||
46 | |||
47 | /**
|
||
48 | * Alter the output generated by Media filter tags.
|
||
49 | *
|
||
50 | * @param array $element
|
||
51 | * The renderable array of output generated for the filter tag.
|
||
52 | * @param array $tag_info
|
||
53 | * The filter tag converted into an associative array by
|
||
54 | * media_token_to_markup() with the following elements:
|
||
55 | * - 'fid': The ID of the media file being rendered.
|
||
56 | * - 'file': The object from file_load() of the media file being rendered.
|
||
57 | * - 'view_mode': The view mode being used to render the file.
|
||
58 | * - 'attributes': An additional array of attributes that could be output
|
||
59 | * with media_get_file_without_label().
|
||
60 | * @param array $settings
|
||
61 | * An additional array of settings.
|
||
62 | * - 'wysiwyg': A boolean if the output is for the WYSIWYG preview or FALSE
|
||
63 | * if for normal rendering.
|
||
64 | *
|
||
65 | * @see media_token_to_markup()
|
||
66 | */
|
||
67 | function hook_media_wysiwyg_token_to_markup_alter(&$element, $tag_info, $settings) { |
||
68 | if (empty($settings['wysiwyg'])) { |
||
69 | $element['#attributes']['alt'] = t('This media has been output using the @mode view mode.', array('@mode' => $tag_info['view_mode'])); |
||
70 | } |
||
71 | } |