Révision fc3d89c3
Ajouté par Assos Assos il y a plus de 7 ans
drupal7/sites/all/modules/media/modules/media_wysiwyg/media_wysiwyg.module | ||
---|---|---|
115 | 115 |
$element['#attached']['library'][] = array('media', 'media_browser_settings'); |
116 | 116 |
|
117 | 117 |
// Add wysiwyg-specific settings. |
118 |
$settings = array('wysiwyg_allowed_attributes' => variable_get('media_wysiwyg_wysiwyg_allowed_attributes', _media_wysiwyg_wysiwyg_allowed_attributes_default())); |
|
118 |
$settings = array( |
|
119 |
'wysiwyg_allowed_attributes' => variable_get('media_wysiwyg_wysiwyg_allowed_attributes', _media_wysiwyg_wysiwyg_allowed_attributes_default()), |
|
120 |
'img_alt_field' => 'field_file_image_alt_text', |
|
121 |
'img_title_field' => 'field_file_image_title_text', |
|
122 |
); |
|
123 |
|
|
124 |
// The file_entity module lets you specify a string, possibly with tokens, for |
|
125 |
// the alt and title attributes of images. We need the actual field names instead. |
|
126 |
// If the variable only contains a token of the format [file:field_file_image_alt_text] |
|
127 |
// then it's possible to extract it. |
|
128 |
$alt_token = variable_get('file_entity_alt', '[file:field_file_image_alt_text]'); |
|
129 |
$title_token = variable_get('file_entity_title', '[file:field_file_image_title_text]'); |
|
130 |
$matches = array(); |
|
131 |
if (preg_match('/^\[file:(field_[[:alnum:]_-]+)\]$/', trim($alt_token), $matches)) { |
|
132 |
$settings['img_alt_field'] = $matches[1]; |
|
133 |
} |
|
134 |
if (preg_match('/^\[file:(field_[[:alnum:]_-]+)\]$/', trim($title_token), $matches)) { |
|
135 |
$settings['img_title_field'] = $matches[1]; |
|
136 |
} |
|
137 |
|
|
119 | 138 |
$element['#attached']['js'][] = array( |
120 | 139 |
'data' => array( |
121 | 140 |
'media' => $settings, |
... | ... | |
288 | 307 |
* |
289 | 308 |
* Optional custom settings can override how the file is displayed. |
290 | 309 |
*/ |
291 |
function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array()) { |
|
310 |
function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = array(), $langcode = NULL) {
|
|
292 | 311 |
$file->override = $settings; |
293 | 312 |
|
294 |
$element = file_view_file($file, $view_mode); |
|
313 |
$element = file_view_file($file, $view_mode, $langcode); |
|
314 |
|
|
315 |
// Field Translation Support. |
|
316 |
if (field_has_translation_handler('file')) { |
|
317 |
if ($field_items = field_get_items('file', $file, 'field_file_image_alt_text', $langcode)) { |
|
318 |
$value = field_view_value('file', $file, 'field_file_image_alt_text', $field_items[0], array(), $langcode); |
|
319 |
$element['#alt'] = isset($value['#markup']) ? $value['#markup'] : ''; |
|
320 |
} |
|
321 |
} |
|
295 | 322 |
|
296 | 323 |
// The formatter invoked by file_view_file() can use $file->override to |
297 | 324 |
// customize the returned render array to match the requested settings. To |
Formats disponibles : Unified diff
Weekly update of contrib modules