You are here

function acquia_lift_profiles_thumbnail_image in Acquia Lift Connector 7.2

Same name and namespace in other branches
  1. 7 acquia_lift_profiles/acquia_lift_profiles.module \acquia_lift_profiles_thumbnail_image()

Given an entity and entity type, returns a thumbnail image.

Parameters

$entity_type: The type of entity to load, e.g., node.

$entity: The entity object (i.e., from node_load, etc.).

$bundle: The bundle to load, e.g., article.

Return value

Acquia Lift Profiles thumbnail image as a full absolute URL or empty string.

1 call to acquia_lift_profiles_thumbnail_image()
acquia_lift_profiles_node_page_context in acquia_lift_profiles/acquia_lift_profiles.module
Handles the node-specific page context request data.

File

acquia_lift_profiles/acquia_lift_profiles.module, line 728
acquia_lift_profiles.module Provides Acquia Lift Profiles integration.

Code

function acquia_lift_profiles_thumbnail_image($entity_type, $entity, $bundle) {
  $image = '';
  $thumbnail = acquia_lift_profiles_thumbnail_get_field($entity_type, $bundle);
  if (empty($thumbnail)) {
    return $image;
  }
  list($field, $widget) = explode(ACQUIA_LIFT_PROFILES_THUMBNAIL_WIDGET_SEPARATOR, $thumbnail);
  $style = acquia_lift_profiles_thumbnail_get_style_field($entity_type, $bundle);
  if ($field) {
    $field_items = field_get_items($entity_type, $entity, $field);
    if (is_array($field_items) && count($field_items) && isset($field_items[0]['uri'])) {

      // If an image style is specified then use it.
      if ($style) {
        $image = image_style_url($style, $field_items[0]['uri']);
      }
      else {
        $image = file_create_url($field_items[0]['uri']);
      }
    }
  }
  return $image;
}