function media_wysiwyg_get_attribute_fields in D7 Media 7.4
Map between html attribute and the file field that feeds it.
2 calls to media_wysiwyg_get_attribute_fields()
- media_wysiwyg_global_js_settings in modules/
media_wysiwyg/ media_wysiwyg.module - Build the global client side settings for wysiwyg editing.
- media_wysiwyg_rebuild_instance_settings in modules/
media_wysiwyg/ includes/ media_wysiwyg.upgrade.inc - Rebuild media token based on schema and allowed overridable fields.
File
- modules/
media_wysiwyg/ media_wysiwyg.module, line 172 - Primarily Drupal hooks.
Code
function media_wysiwyg_get_attribute_fields() {
$map = array(
'alt' => 'field_file_image_alt_text',
'title' => 'field_file_image_title_text',
);
// The file_entity module lets you specify a string, possibly with tokens, for
// the alt and title attributes of images. We need the actual field names
// instead. If the variable only contains a token of the format
// [file:field_file_image_alt_text] then it's possible to extract it.
$alt_token = variable_get('file_entity_alt', '[file:field_file_image_alt_text]');
$title_token = variable_get('file_entity_title', '[file:field_file_image_title_text]');
$matches = array();
if (preg_match('/^\\[file:(field_[[:alnum:]_-]+)\\]$/', trim($alt_token), $matches)) {
$map['alt'] = $matches[1];
}
if (preg_match('/^\\[file:(field_[[:alnum:]_-]+)\\]$/', trim($title_token), $matches)) {
$map['title'] = $matches[1];
}
return $map;
}