View source
<?php
function ad_field_formatter_info() {
$formatters = array(
'ad_image' => array(
'label' => t('Ad Image'),
'field types' => array(
'image',
),
),
);
return $formatters;
}
function ad_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
$destination = ad_get_destination($entity);
if (!empty($destination)) {
$uri = 'ad/click/' . $entity->nid . '/' . AD_IMPRESSION_ID_PLACEHOLDER;
}
else {
$uri = '';
}
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#theme' => 'image_formatter',
'#item' => $item,
'#image_style' => '',
'#path' => isset($uri) ? array(
'path' => $uri,
) : '',
);
}
return $element;
}