Created
June 17, 2011 19:38
-
-
Save jeremyboggs/1032140 to your computer and use it in GitHub Desktop.
Displays a simple JavaScript-powered image gallery for an Omeka item. Clicking on a thumbnail displays its larger image. Requires jQuery.
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
<?php | |
/** | |
* Displays a simple JavaScript-powered image gallery for an Omeka item. | |
* Clicking on a thumbnail displays its larger image. Requires jQuery. | |
* | |
* @param Item|null $item Check for this specific item record (current item if null). | |
* @return string HTML | |
*/ | |
function display_image_gallery_for_item($item = null) | |
{ | |
if (!$item) { | |
$item = get_current_item(); | |
} | |
$html = ''; | |
$images = get_db()->getTable('File')->findWithImages($item->id); | |
if ($images) { | |
$html = '<div id="image-gallery-for-item">' | |
. display_files($images) | |
. '</div>' | |
. '<script>' | |
. 'jQuery(document).ready(function($){' | |
. 'var firstImg = $("#image-gallery-for-item a:first-child").attr("href");' | |
. 'var bigImg = $("<img>").prependTo("#image-gallery-for-item");' | |
. 'bigImg.attr("src", firstImg).css({"max-width": "100%"});' | |
. '$("#image-gallery-for-item a").click(function(){' | |
. 'bigImg.attr("src", $(this).attr("href"));' | |
. 'return false;' | |
. '});' | |
. '});' | |
. '</script>'; | |
} | |
return $html; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment