function _amp_get_image_information in Accelerated Mobile Pages (AMP) 7
Gets image information.
Parameters
string $image_url: The absolute URL of the image. URL should include 'http'.
string $image_uri: The URI of the image. URI should begin with 'public://'.
string $image_style_id: The optional ID of the image style.
Return value
array The array containing information about the image. Return an empty array if there is a problem getting information about the image. Otherwise the image inforation array includes the following keys:
- url
- width
- height
1 call to _amp_get_image_information()
- amp_node_view in ./
amp.module - Implements hook_node_view().
File
- ./
amp.module, line 1684
Code
function _amp_get_image_information($image_url, $image_uri, $image_style_id) {
$image_width = '';
$image_height = '';
if (!empty($image_uri) && FALSE !== image_get_info($image_uri)) {
$image_info = image_get_info($image_uri);
$image_dimensions = array(
'width' => $image_info['width'],
'height' => $image_info['height'],
);
if (!empty($image_style_id)) {
$image_url = image_style_url($image_style_id, $image_uri);
image_style_transform_dimensions($image_style_id, $image_dimensions);
}
$image_width = $image_dimensions['width'];
$image_height = $image_dimensions['height'];
}
if (!empty($image_url) && !empty($image_width) & !empty($image_height)) {
return array(
'url' => $image_url,
'width' => $image_width,
'height' => $image_height,
);
}
else {
return array();
}
}