diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index a287620..fbfc2de 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -461,21 +461,34 @@ function theme_image_widget($variables) { * @ingroup themeable */ function theme_image_formatter($variables) { - $item = $variables['item']; - - // Do not output an empty 'title' attribute. - if (isset($item['title']) && drupal_strlen($item['title']) == 0) { - unset($item['title']); - } + $image = array(); + $hooks = theme_get_registry(FALSE); + // Applying an image style if exists. if ($variables['image_style']) { - $item['style_name'] = $variables['image_style']; - $output = theme('image_style', $item); + $info = $hooks['image_style']; + $image['#theme'] = 'image_style'; + $image['#style_name'] = $variables['image_style']; } else { - $output = theme('image', $item); + $info = $hooks['image']; + $image['#theme'] = 'image'; + } + + // Populating all needed values from variables. + foreach (array_keys($info['variables']) as $name) { + if (isset($variables['item']["$name"])) { + $image["#$name"] = $variables['item']["$name"]; + } + } + + // Removing the title variable if empty. + if (isset($image['#title']) && drupal_strlen($image['#title']) == 0) { + unset($image['#title']); } + $output = drupal_render($image); + // The link path and link options are both optional, but for the options to be // processed, the link path must at least be an empty string. if (isset($variables['path']['path'])) {