function responsive_image_get_image_dimensions

responsive_image_get_image_dimensions($image_style_name, array $dimensions, $uri)

Determines the dimensions of an image.

Parameters

string $image_style_name: The name of the style to be used to alter the original image.

array $dimensions: An associative array containing:

  • width: The width of the source image (if known).
  • height: The height of the source image (if known).

string $uri: The URI of the image file.

Return value

array Dimensions to be modified - an array with components width and height, in pixels.

File

core/modules/responsive_image/responsive_image.module, line 448
Responsive image display formatter for image fields.

Code

function responsive_image_get_image_dimensions($image_style_name, array $dimensions, $uri) {
  // Determine the dimensions of the styled image.
  if ($image_style_name == RESPONSIVE_IMAGE_EMPTY_IMAGE) {
    $dimensions = array(
      'width' => 1,
      'height' => 1,
    );
  }
  elseif ($entity = ImageStyle::load($image_style_name)) {
    $entity->transformDimensions($dimensions, $uri);
  }

  return $dimensions;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!modules!responsive_image!responsive_image.module/function/responsive_image_get_image_dimensions/8.1.x