function caption_edit_form($imagefile, $gallery, $dirkey, $filekey) { $caption = htmlspecialchars(get_caption($imagefile)); // Display input form print <<<EOH <form action="gallery.php" method="post" > <div class="caption_input" > Edit caption: <br/> <textarea class="caption_input" name="caption" cols="40" rows="1" >{$caption}</textarea> <input type="submit" name="caption_submit" value="Go" /> </div> <input type="hidden" name="imagefile" value="{$gallery}" /> <input type="hidden" name="imagefile" value="{$dirkey}" /> <input type="hidden" name="imagefile" value="{$filekey}" /> <input type="hidden" name="action" value="write_caption" /> </form> EOH; }
function JPEG_Thumbnail($filelist, $gallery, $dirkey, $filekey, $basedir) { #include_once("generate_filelist.php"); #$filelist = generate_filelist($gallery, $dirkey); $filename = $filelist[$filekey]; $file = "{$basedir}/{$filename}"; $caption = get_caption($file); if (!isset($caption) || $caption == "") { $caption = $filename; } #$imagecache=dirname(__FILE__)."/imagecache"; $random = rand(1000, 999999); $imagetag = "<img class=thumbnail src='image_resample.php?gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}&size=150&xx={$random}' title='{$caption}'>"; print <<<HTMLEND <div class=thumbnail> <a class=thumbnail href='gallery.php?gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}&size=700&action=display_image'> {$imagetag} </a> </div> HTMLEND; // END OF FUNCTION Thumbnail }
function display_image_section($gallery, $dirkey, $filekey, $size, $xsize, $ysize) { include "set_paths.php"; include "{$imagedata}/{$gallery}"; if (!isset($_GLOBAL['filelist'])) { include_once "generate_filelist.php"; $filelist = generate_filelist($gallery, $dirkey); } else { $filelist = $_GLOBAL['filelist']; } $numfiles = count($filelist); #$imagecache=dirname(__FILE__)."/imagecache"; $basedir = $dirs[$dirkey]; if (preg_match("/\\.(mov|mpg|mpeg|avi|mp4)\$/i", $filelist[$filekey])) { $type = "movie"; } // Create next image href #$nexttag = "<span class='nav_inactive' >Next>></span>"; if ($filekey + 1 >= $numfiles) { $nextfile = $filelist[0]; $nextfile = "{$basedir}/{$nextfile}"; $nexttag = "<a class='prevnext_active' href='gallery.php?filekey=0&size=700&action=display_image'>|<<Back to start</a>"; } else { $nextkey = $filekey + 1; $nextfile = $filelist[$nextkey]; $nextfile = "{$basedir}/{$nextfile}"; $nexttag = "<a class='prevnext_active' href='gallery.php?filekey={$nextkey}&size=700&action=display_image'>Next>></a>"; } // Create href to previous image if ($filekey == 0) { # We are at first image so don't show next link - just inactive. $prevtag = "<span class='prevnext_inactive' ><<Previous</span>"; } else { $prevkey = $filekey - 1; $prevfile = $filelist[$prevkey]; $prevfile = "{$basedir}/{$prevfile}"; $prevtag = "<a class='prevnext_active' href='gallery.php?&filekey={$prevkey}&size=700&action=display_image'><<Previous</a>"; } // Use random number so that browser cache does not mistake this for the same picture each time $random = rand(1000, 9999); #$imagefile=$_SESSION['imagefile']; $imagefile = "{$basedir}/" . $filelist[$filekey]; $_GLOBAL['caption'] = get_caption($imagefile); $caption = $_GLOBAL['caption']; // Menu line if ($type != "movie") { ?> <div class="imagenavigate" > <?php include "resize_menu.php"; print "\n<span id='resize_menu'>\n"; display_resize_menu($filekey); print "</span>\n"; } else { //Display fake resize menu as placeholder print "\n<ul class='nav' ><li> </li></ul>\n"; } print <<<EOH <span class="prevnext" > {$prevtag} {$nexttag} </span> EOH; if ($_SESSION['edit']) { print <<<EOH <span id="edit_caption_link" > <a href="?gallery={$gallery}&action=edit_caption&filekey={$filekey}&dirkey={$dirkey}&size={$size}" > Edit Caption </a> </span> </div><br/> EOH; } #if ( $_SESSION['action'] != 'edit_caption' && authorise_user('edit_caption') ){ if ($_SESSION['action'] != 'edit_caption') { // display caption print <<<EOH \t<br/> <span id="caption" >{$caption}</span> EOH; print "\n<br/>\n"; } elseif ($_SESSION['action'] == 'edit_caption') { // display caption in an editable text box $filepath = $dirs[$dirkey] . "/" . $filelist[$filekey]; caption_edit_form($filepath, $gallery, $dirkey, $filekey); print "<br/>\n"; } else { // no edit functions requested, just write the caption print <<<EOH <span id="caption" >{$caption}</span><br/> EOH; } // Display image if (preg_match_all("/\\.(mov|mpg|mpeg|avi|mp4)\$/i", $filelist[$filekey], $matches)) { $mimetype = mime_content_type($dirs[$dirkey] . "/" . $filelist[$filekey]); $parts = $matches[0]; $type = $parts[0]; #$filename="$basedir/${filelist[$filekey]}"; #<embed type="video/x-msvideo" src='send_file.php?mode=stream&gallery=$gallery&dirkey=$dirkey&filekey=$filekey' width=640 height=480 > #<object type="video/avi" data='send_file.php?mode=stream&gallery=$gallery&dirkey=$dirkey&filekey=$filekey' width=640 height=480 > echo <<<HTMLEND <span class="center" >This file "{$filelist[$filekey]}" is a "{$mimetype}" movie file.<br/> <a href='send_file.php?mode=stream&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}' type='{$mimetype}' >Click here to play it</a> <br/> <a href='send_file.php?mode=attach&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}'> <b>Click here to download it.</b></a></span><br> HTMLEND; } else { #if ( $_SESSION['size'] == "full" ) { if ($size == "full") { $filekey = $_SESSION['filekey']; $filelist = $_SESSION['filelist']; $basedir = $_SESSION['basedir']; $filename = $filelist[$filekey]; $src_imgfile = "{$basedir}/{$filename}"; if (!isset($caption) || $caption == "") { $caption = $filename; } echo <<<HTMLEND \t<img src="send_file.php?mode=stream&gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}" title="{$caption}" > HTMLEND; } else { if (!isset($caption) || $caption == "") { $caption = basename($imagefile); } if ($size > 10) { $urlsize = "size={$size}"; } else { $urlsize = "xsize={$xsize}&ysize={$ysize}"; } $filekey = $_SESSION['filekey']; $dirkey = $_SESSION['dirkey']; echo <<<HTMLEND \t<img src="image_resample.php?gallery={$gallery}&dirkey={$dirkey}&filekey={$filekey}&{$urlsize}&xxx={$random}" title="{$caption}"> HTMLEND; } print "\n\n<br/>\n\n"; show_exif_button(); display_exif("{$basedir}/" . $filelist[$filekey]); } }
function get_photos($post_id, $num = 0, $sizes = null, $ret = null, $landscape = null) { // save the image with the highest priority // to use when returing only one image $top_priority['priority'] = 9999; // check if there are attachments if ($images = get_children(array('post_parent' => $post_id, 'post_type' => 'attachment', 'order' => 'ASC', 'orderby' => 'menu_order', 'post_mime_type' => 'image'))) { // loop through each image foreach ($images as $image) { $image->attachment_metadata = wp_get_attachment_metadata($image->ID); if (isset($photo['photos'])) { $i = count($photo['photos']); } else { $i = 0; } // store image information $photo['photos'][$i]['id'] = get_id($image); $photo['photos'][$i]['caption'] = get_caption($image); $photo['photos'][$i]['credit'] = get_credit($image); $photo['photos'][$i]['priority'] = get_priority($image); $photo['photos'][$i]['width'] = get_width($image); $photo['photos'][$i]['height'] = get_height($image); // return requested sizes if ($sizes) { foreach ($sizes as $size) { $photo['photos'][$i]['src'][$size] = get_src($image, $size); } } else { // return all sizes when none are specified $photo['photos'][$i]['src']['full'] = get_src($image, 'full'); $photo['photos'][$i]['src']['large'] = get_src($image, 'large'); $photo['photos'][$i]['src']['thumbnail'] = get_src($image, 'thumbnail'); $photo['photos'][$i]['src']['medium'] = get_src($image, 'medium'); $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline'); $photo['photos'][$i]['src']['alt-thumbnail'] = get_src($image, 'alt-thumbnail'); $photo['photos'][$i]['src']['custom-495'] = get_src($image, 'custom-495'); $photo['photos'][$i]['src']['custom-165'] = get_src($image, 'custom-165'); $photo['photos'][$i]['src']['custom-260'] = get_src($image, 'custom-260'); $photo['photos'][$i]['src']['custom-75x75-crop'] = get_src($image, 'custom-75x75-crop'); } // store the photo with the highest priority in wordpress. // photos with high priorities are given low numbers. // photos with priority of -1 are ignored. if ($num === 1 && $photo['photos'][$i]['priority'] < $top_priority['priority'] && $photo['photos'][$i]['priority'] >= 0) { // if user wants a landscape photo, check // to make sure it is landscape if ($landscape && !is_landscape($image)) { continue; } $top_priority = $photo['photos'][$i]; } // determine image position based on priority if (!isset($photo['display']['feature']) && get_priority($image) === 1) { // feature photo - below headline $photo['display']['feature'] = $i; $photo['photos'][$i]['src']['single-feature'] = get_src($image, 'single-feature'); } elseif (!isset($photo['display']['inline']) && get_priority($image) === 2) { // inline photo - thumbnail w/in post $photo['display']['inline'] = $i; $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline'); } else { if (!isset($photo['display']['inline'])) { // inline photo has not been set $photo['display']['inline'] = $i; $photo['photos'][$i]['src']['single-inline'] = get_src($image, 'single-inline'); } else { // gallery photo - appears in post photo gallery if (isset($photo['display']['gallery'])) { $photo['display']['gallery'][count($photo['display']['gallery'])] = $i; } else { $photo['display']['gallery'][0] = $i; } } } // return first photo when one is requested and there is only one if ($num === 1 && count($images) == 1) { return $photo['photos'][$i]; } } // returns top photo when one is requested. // if user only wants one landscape photo, // but the top_priority is not landscape, don't // return anything. if ($num === 1) { if ($landscape && !is_landscape($image)) { return false; } return $top_priority; } // return all of the requested photos return $photo; } else { // check if the image is from the archives. images on our old // websites (custom CMS for some time then College Publisher) // were not saved as attachments, but were stored as custom // fields. $meta = get_post_custom($post_id); if ($meta && isset($meta['_image1'])) { $meta['_image1'] = get_image($meta['_image1']); // needed to make legacy photo output look like current photos $photo['photos'][0] = $meta['_image1']; $photo['photos'][0]['priority'] = 0; $photo['display']['inline'] = 0; if ($num === 1) { return $photo['photos'][0]; } return $photo; } } // no images were found return false; }