Created
October 20, 2012 19:56
-
-
Save ChrisLTD/3924562 to your computer and use it in GitHub Desktop.
Drupal 7 image gallery output
This file contains 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
// Requires Content Type with image field with multiple images as described here: http://drupal.stackexchange.com/a/5901 | |
// Title is output as caption if there is title text | |
// Image size is determined by custom image style in Drupal admin named "gallery_thumb" | |
<?php | |
$gallery_images = $node->field_gallery_image['und']; | |
for($i = 0; $i < count($gallery_images); $i++) { | |
$image = $gallery_images[$i]; | |
$output = '<a href="' . file_create_url($image['uri']) . '">'; | |
$output .= '<img src="' . image_style_url("gallery_thumb", $image['uri']) . '">'; | |
if($image['title'] != ""){ | |
$output .= '<span>' . $image['title'] . '</span>'; | |
} | |
$output .= '</a>'; | |
echo $output; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment