diff --git a/modules/media_wysiwyg/media_wysiwyg.module b/modules/media_wysiwyg/media_wysiwyg.module index 388d3ab..1a6d32b 100644 --- a/modules/media_wysiwyg/media_wysiwyg.module +++ b/modules/media_wysiwyg/media_wysiwyg.module @@ -341,8 +341,13 @@ function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = arr // @todo This assumes a particular token pattern that may not be valid. if ($token_pattern == "[file:$field_name]") { // Find the display value of this field in the current display - // language. - $text = token_replace($token_pattern, array('file' => $file), array('clear' => TRUE, 'sanitize' => FALSE)); + // language, using the overrides for this field that are stored in + // the settings. + $file_with_overrides = clone $file; + foreach ($fields_by_language as $langcode => $field_data) { + $file_with_overrides->{$field_name}[$langcode] = $field_data; + } + $text = token_replace($token_pattern, array('file' => $file_with_overrides), array('clear' => TRUE, 'sanitize' => FALSE)); // If the overridden attribute value does not match the current // display value of the field, proceed to check if it matches a // different language instead. @@ -350,7 +355,7 @@ function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = arr $langcodes = array_keys($fields_by_language); if ($langcodes) { // Leave off the current display language which was used above. - $field_language = field_language('file', $file, $field_name); + $field_language = field_language('file', $file_with_overrides, $field_name); $langcodes = array_diff($langcodes, array($field_language)); } if ($langcodes) { @@ -362,7 +367,7 @@ function media_wysiwyg_get_file_without_label($file, $view_mode, $settings = arr if (isset($languages[$langcode])) { // Check the display value of the field in the candidate // language. - $text = token_replace($token_pattern, array('file' => $file), array('clear' => TRUE, 'sanitize' => FALSE, 'language' => $languages[$langcode])); + $text = token_replace($token_pattern, array('file' => $file_with_overrides), array('clear' => TRUE, 'sanitize' => FALSE, 'language' => $languages[$langcode])); // If it matches the overridden attribute value, assume the // attribute override was for that language, and don't use it // here.