function theme_image_style

7.x image.module theme_image_style($variables)

Returns HTML for an image using a specific image style.

Parameters

$variables: An associative array containing:

  • style_name: The name of the style to be used to alter the original image.
  • path: The path of the image file relative to the Drupal files directory. This function does not work with images outside the files directory nor with remotely hosted images. This should be in a format such as 'images/image.jpg', or using a stream wrapper such as 'public://images/image.jpg'.
  • width: The width of the source image (if known).
  • height: The height of the source image (if known).
  • alt: The alternative text for text-based browsers.
  • title: The title text is displayed when the image is hovered in some popular browsers.
  • attributes: Associative array of attributes to be placed in the img tag.

Related topics

1 call to theme_image_style()
ImageDimensionsTestCase::testImageDimensions in drupal/modules/image/image.test
Test styled image dimensions cumulatively.
3 theme calls to theme_image_style()
image_field_widget_process in drupal/modules/image/image.field.inc
An element #process callback for the image_image field type.
template_preprocess_user_picture in drupal/modules/user/user.module
Process variables for user-picture.tpl.php.
theme_image_formatter in drupal/modules/image/image.field.inc
Returns HTML for an image field formatter.
27 string references to the theme hook from theme_image_style()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

ImageAdminStylesUnitTest::testStyleReplacement in drupal/modules/image/image.test
Test deleting a style and choosing a replacement style.
ImageFieldDisplayTestCase::_testImageFieldFormatters in drupal/modules/image/image.test
Test image formatters on node display.
image_effect_delete_form in drupal/modules/image/image.admin.inc
Form builder; Form for deleting an image effect.
image_effect_delete_form_submit in drupal/modules/image/image.admin.inc
Submit handler to delete an image effect.
image_effect_form in drupal/modules/image/image.admin.inc
Form builder; Form for adding and editing image effects.

... See full list

File

drupal/modules/image/image.module, line 1368
Exposes global functionality for creating image styles.

Code

function theme_image_style($variables) {
  // Determine the dimensions of the styled image.
  $dimensions = array(
    'width' => $variables['width'],
    'height' => $variables['height'],
  );

  image_style_transform_dimensions($variables['style_name'], $dimensions);

  $variables['width'] = $dimensions['width'];
  $variables['height'] = $dimensions['height'];

  // Determine the URL for the styled image.
  $variables['path'] = image_style_url($variables['style_name'], $variables['path']);
  return theme('image', $variables);
}