Last active
May 4, 2018 19:35
-
-
Save init90/64e918a0a71dca0de1a812f21e2c2e73 to your computer and use it in GitHub Desktop.
Drupal 7. Preproccess colorbox images.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Implements template_preprocess_field | |
*/ | |
function THEME_preprocess_field(&$vars) { | |
// Display first image in colorbox gallery preview. | |
if (isset($vars['element']['#field_name']) && $vars['element']['#field_name'] == 'field_product_image') { | |
if (isset($vars['items'][0]['#theme']) && ($vars['items'][0]['#theme'] == 'colorbox_image_formatter')) { | |
$first_photo_copy = $vars['items'][0]; | |
// Disable copy image in gallery, use only for preview. | |
$first_photo_copy['#display_settings']['colorbox_gallery'] = 'none'; | |
// Add copy image to colorbox gallery. | |
array_push($vars['items'], $first_photo_copy); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment