commit 117de8f2a9ed2fadfcb1a6ba58a3331bde5805ab Author: Shane Auckland Date: Tue Apr 16 16:59:45 2013 +0100 1898420-new_changes diff --git a/core/modules/image/image.admin.inc b/core/modules/image/image.admin.inc index 7990ca3..c4dd667 100644 --- a/core/modules/image/image.admin.inc +++ b/core/modules/image/image.admin.inc @@ -726,7 +726,10 @@ function template_preprocess_image_style_preview(&$variables) { $variables['original_attributes'] = new Attribute($original_attributes); $original_attributes['src'] = file_create_url($original_path); $original_attributes['alt'] = t('Sample original image'); - $variables['original_image_attributes'] = new Attribute($original_attributes); + $variables['original_image'] = array( + '#theme' => 'image', + '#attributes' => new Attribute($original_attributes), + ); $variables['original_image_height'] = $original_image['height']; $variables['original_image_width'] = $original_image['width']; $variables['original_height'] = $original_height; @@ -737,7 +740,10 @@ function template_preprocess_image_style_preview(&$variables) { $variables['preview_attributes'] = new Attribute($preview_attributes); $preview_attributes['src'] = file_create_url($preview_file) . '?cache_bypass=' . REQUEST_TIME; $preview_attributes['alt'] = t('Sample modified image'); - $variables['preview_image_attributes'] = new Attribute($preview_attributes); + $variables['preview_image'] = array( + '#theme' => 'image', + '#attributes' => new Attribute($preview_attributes), + ); $variables['preview_image_height'] = $preview_image['height']; $variables['preview_image_width'] = $preview_image['width']; $variables['preview_height'] = $preview_height; @@ -761,7 +767,9 @@ function template_preprocess_image_anchor(&$variables) { foreach (element_children($element) as $n => $key) { $element[$key]['#attributes']['title'] = $element[$key]['#title']; unset($element[$key]['#title']); - $row[] = drupal_render($element[$key]); + $row[] = array( + 'data' => $element[$key], + ); if ($n % 3 == 3 - 1) { $rows[] = $row; $row = array(); @@ -797,13 +805,17 @@ function template_preprocess_image_resize_summary(&$variables) { $output = ($data['width']) ? t('width @width', array('@width' => $data['width'])) : t('height @height', array('@height' => $data['height'])); } + if(isset($data['upscale'])) { + $output .= ' (' . t('upscaling allowed') . ')'; + } + $variables['summary'] = $output; } /** * Prepares variables for image scale summary templates. * - * Default template: image-scale-summary,html.twig + * Default template: image-scale-summary.html.twig * * @param array $variables * An associative array containing: @@ -811,13 +823,16 @@ function template_preprocess_image_resize_summary(&$variables) { */ function template_preprocess_image_scale_summary(&$variables) { $data = $variables['data']; - $variables['summary'] = theme('image_resize_summary', array('data' => $data)) . ' ' . ($data['upscale'] ? '(' . t('upscaling allowed') . ')' : ''); + $variables['summary'] = array( + '#theme' => 'image_resize_summary', + '#data' => $data, + ); } /** * Prepares variables for image crop summary templates. * - * Default template: image-crop-summary,html.twig + * Default template: image-crop-summary.html.twig * * @param array $variables * An associative array containing: diff --git a/core/modules/image/image.field.inc b/core/modules/image/image.field.inc index 55b529f..4da6e41 100644 --- a/core/modules/image/image.field.inc +++ b/core/modules/image/image.field.inc @@ -427,7 +427,6 @@ function _image_field_required_fields_validate($element, &$form_state) { * - element: An associative array containing the image field widget. */ function template_preprocess_image_widget(&$variables) { - die("image preprocess"); $element = $variables['element']; $element['#attributes']['class'] = array('image-widget', 'form-managed-file', 'clearfix'); @@ -448,7 +447,7 @@ function template_preprocess_image_widget(&$variables) { * * Default template: image-formatter.html.twig. * - * @param array $varialbes + * @param array $variables * An associative array containing: * - item: the formatter item */ diff --git a/core/modules/image/image.module b/core/modules/image/image.module index 1c6a44f..68eabdd 100644 --- a/core/modules/image/image.module +++ b/core/modules/image/image.module @@ -224,49 +224,42 @@ function image_theme() { ), 'image_style_preview' => array( 'variables' => array('style' => NULL), - 'template' => 'image-style-preview', 'file' => 'image.admin.inc', + 'template' => 'image-style-preview', ), 'image_anchor' => array( 'render element' => 'element', - 'template' => 'image-anchor', 'file' => 'image.admin.inc', + 'template' => 'image-anchor', ), 'image_resize_summary' => array( 'variables' => array('data' => NULL), - 'template' => 'image-resize-summary', 'file' => 'image.admin.inc', + 'template' => 'image-resize-summary', ), 'image_scale_summary' => array( 'variables' => array('data' => NULL), - 'template' => 'image-scale-summary', 'file' => 'image.admin.inc', + 'template' => 'image-scale-summary', ), 'image_crop_summary' => array( 'variables' => array('data' => NULL), - 'template' => 'image-crop-summary', 'file' => 'image.admin.inc', + 'template' => 'image-crop-summary', ), 'image_rotate_summary' => array( 'variables' => array('data' => NULL), - 'template' => 'image-rotate-summary', 'file' => 'image.admin.inc', + 'template' => 'image-rotate-summary', ), // Theme functions in image.field.inc. 'image_widget' => array( 'render element' => 'element', - 'template' => 'image-widget', - 'file' => 'image.field.inc', ), 'image_formatter' => array( - 'variables' => array( - 'item' => NULL, - 'path' => NULL, - 'image_style' => NULL - ), + 'variables' => array('item' => NULL, 'path' => NULL, 'image_style' => NULL), 'template' => 'image-formatter', - 'file' => 'image.field.inc', ), ); } diff --git a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php index e7552d2..eadbf5d 100644 --- a/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php +++ b/core/modules/image/lib/Drupal/image/Tests/ImageDimensionsTest.php @@ -69,7 +69,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -90,7 +90,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -112,7 +112,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -134,7 +134,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -152,7 +152,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -173,7 +173,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -193,7 +193,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -214,7 +214,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); $this->assertFalse(file_exists($generated_uri), 'Generated file does not exist.'); $this->drupalGet($url); @@ -232,7 +232,7 @@ function testImageDimensions() { ); image_effect_save($style, $effect); - $img_tag = theme_image_style($variables); + $img_tag = theme('image_style', $variables); $this->assertEqual($img_tag, ''); } } diff --git a/core/modules/image/templates/image-formatter.html.twig b/core/modules/image/templates/image-formatter.html.twig index c2c0284..a78f0f4 100644 --- a/core/modules/image/templates/image-formatter.html.twig +++ b/core/modules/image/templates/image-formatter.html.twig @@ -9,10 +9,6 @@ * - path: An optional array containing the link 'path' and link 'options'. * - url: An optional url the image can be linked to. * - * @TODO: Make twig able to find templates as per http://drupal.org/node/1777532 - * @todo: Revise template_preprocess_image_formatter to make this template - * more meaningful. - * * @see template_preprocess() * @see template_preprocess_image_formatter() * diff --git a/core/modules/image/templates/image-style-preview.html.twig b/core/modules/image/templates/image-style-preview.html.twig new file mode 100644 index 0000000..e9a40e2 --- /dev/null +++ b/core/modules/image/templates/image-style-preview.html.twig @@ -0,0 +1,54 @@ +{# +/** + * @file + * Default theme implementation to display a preview of an image style. + * + * Available variables: + * - style_name: The name of the image style. + * - original_image_height: The height in pixels of the original image. + * - original_image_width: The width in pixels of the original image. + * - original_height: The lesser of original_image_height or sample image + * height. + * - original_width: The lesser of original_image_width or sample image width. + * - original_url: The URL of the original image. + * - original_attributes: HTML attributes for the original style. + * - original_image: The rendered original image. + * - preview_image_height: The height in pixels of the preview image. + * - preview_image_width: The width in pixels of the preview image. + * - preview_height: The lesser of preview_image_height or sample image height. + * - preview_width: The lesser of preview_image_width or sample image width. + * - preview_url: The URL of the preview image. + * - preview_attributes: HTML attributes for the preview style. + * - preview_image: HThe rendered preview image.. + * + * @see template_preprocess() + * @see template_preprocess_image_style_preview() + * + * @ingroup themeable + */ +#} +
+ {# Preview of the original image. #} +
+ {{ 'original' | t }} ({{ 'view actual size'|t }}) +
+ + {{ original_image }} + +
{{ original_image_height }}px
+
{{ original_image_width }}px
+
+
{# End preview-image-wrapper. #} + + {# Preview of the image style. #} +
+ {{ style_name }} ({{ 'view actual size'|t }}) +
+ + {{ preview_image }} + +
{{ preview_image_height }}px
+
{{ preview_image_width }}px
+
+
{# End preview-image-wrapper. #} +