I found my way of doing this. It's a litle bit tricky, but I hope it helps.
1) Get a View where you grab all node's fields, one of them is the "image" (multi-value).
2) To create a Custom Formatter with the Field API, put this code in a custom module (e.g. mymodule):
/**
* Implements hook_field_formatter_info().
*/
function mymodule_field_formatter_info() {
return array(
'mymodule_formatter' => array( //Machine name of the formatter
'label' => t('Links to images'),
'field types' => array('image'), //This will only be available to text fields
),
);
}
/**
* Implements hook_field_formatter_view().
*/
function mymodule_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array(); // Initialize the var
$settings = $display['settings']; // get the settings
//get first image
$firstimg = $items[0];
$uri = file_create_url(file_load($firstimg['fid'])->uri);
$html = '<img src="'. $uri. '" id="galeria1-button" class="btnSlideshow" href="#" />'. PHP_EOL;
//get all images and put them as links but without being seen
$options = array(
'html' => TRUE, // This tells Drupal that we're sending HTML, not plain text, otherwise it would encode it
'attributes' => array(
'class' => 'galeria1',
),
);
foreach ($items as $delta => $item) {
$uri = file_create_url(file_load($item['fid'])->uri);
$html.= l(' ', $uri, $options);
}
//js will make that when you click on first image its as if you were clicking on first gallery image
drupal_add_js('jQuery(document).ready(function(){jQuery("#galeria1-button").click(function(){jQuery(".galeria1").filter(":first").click();}); jQuery(".galeria1").colorbox({rel:\'galeria1\'});});', 'inline');
$elements[0] = array('#markup' => $html);
return $elements;
}