Created
May 15, 2012 19:44
-
-
Save jeremyboggs/2704505 to your computer and use it in GitHub Desktop.
Change the link around images files in Omeka to point to the fullsize image, not the archival image.
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 | |
/** | |
* Change the link around images files in Omeka to point to the | |
* fullsize image, not the archival image. | |
* | |
* Uses the 'display_file' filter in Omeka 1.5. | |
*/ | |
function link_images_to_fullsize($html, $file, $callback, $options, $wrapperAttributes) { | |
// If the file has a fullsize derivatrive. | |
if ($file->hasFullsize()) { | |
$helper = new Omeka_View_Helper_Media; | |
// Set the linkAttribute 'href' option to file_display_uri for the $file. | |
$options['linkAttributes']['href'] = file_display_uri($file); | |
// Sets the $html to the Omeka_View_Helper_Media::image method. | |
$html = $helper->image($file, $options); | |
// Our $html still doesn't have the wrapper, so we need to check for that | |
// here, and wrap $html accordingly. | |
$wrapper = !empty($wrapperAttributes) ? '<div ' . _tag_attributes($wrapperAttributes) . '>' : ''; | |
$html = !empty($wrapper) ? $wrapper . $html . "</div>" : $html; | |
} | |
return $html; | |
} | |
add_filter('display_file', 'link_images_to_fullsize'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment