function responsive_image_get_image_dimensions

Same name in other branches
  1. 8.9.x core/modules/responsive_image/responsive_image.module \responsive_image_get_image_dimensions()
  2. 10 core/modules/responsive_image/responsive_image.module \responsive_image_get_image_dimensions()
  3. 11.x core/modules/responsive_image/responsive_image.module \responsive_image_get_image_dimensions()

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.

1 call to responsive_image_get_image_dimensions()
_responsive_image_build_source_attributes in core/modules/responsive_image/responsive_image.module
Helper function for template_preprocess_responsive_image().

File

core/modules/responsive_image/responsive_image.module, line 443

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.