You are here

function template_preprocess_amazon_image in Amazon Product Advertisement API 8.2

Prepares variables for the amazon-image Twig template.

Parameters

array $variables: Array of variables including the results of the APA API call.

File

./amazon.module, line 85
Provides the easy integration of the Amazon Product Advertising API.

Code

function template_preprocess_amazon_image(&$variables) {
  switch ($variables['size']) {
    case 'small':
      $image = $variables['results'][0]->SmallImage;
      break;
    case 'medium':
      $image = $variables['results'][0]->MediumImage;
      break;
    case 'large':
      $image = $variables['results'][0]->LargeImage;
      break;
  }
  $variables['image_src'] = (string) $image->URL;
  $variables['width'] = (string) $image->Width;
  $variables['height'] = (string) $image->Height;
  $variables['url'] = $variables['results'][0]->DetailPageURL;
}