function yashare_entity_view in Yandex.Share 7.2
Implements hook_entity_view().
File
- ./
yashare.module, line 120
Code
function yashare_entity_view($entity, $type, $view_mode, $langcode) {
$entity->content['yashare'] = _yashare_widget_view($entity, $type);
// Get entity bundle and load settings.
list(, , $bundle) = entity_extract_ids($type, $entity);
$field_bundle_setting = field_bundle_settings($type, $bundle);
// Determine the view_mode settings to use.
$effective_view_mode = 'default';
if (isset($field_bundle_setting['view_modes'][$view_mode]) && $field_bundle_setting['view_modes'][$view_mode]['custom_settings']) {
$effective_view_mode = $view_mode;
}
if (isset($field_bundle_setting['extra_fields']['display']['yashare'][$effective_view_mode]['settings'])) {
$settings = $field_bundle_setting['extra_fields']['display']['yashare'][$effective_view_mode]['settings'];
// Add image to share according to settings.
if ($items = field_get_items($type, $entity, $settings['image_field'])) {
if ($settings['image_style']) {
$entity->content['yashare']['#image'] = image_style_url($settings['image_style'], $items[0]['uri']);
}
else {
$entity->content['yashare']['#image'] = file_create_url($items[0]['uri']);
}
}
// Add description.
if (isset($settings['description'])) {
$entity->content['yashare']['#description'] = token_replace($settings['description'], array(
$type => $entity,
));
}
}
}