# HG changeset patch # User edogawaconan # Date 1413907975 -32400 # Node ID c2a468e9f3ac082439f7c507579c7ac316a2a310 # Parent b6b65a5b9c1a0df1954bad934a368cacd972db86 Add lightbox support \o/ diff -r b6b65a5b9c1a -r c2a468e9f3ac index.php --- a/index.php Wed Oct 22 00:08:07 2014 +0900 +++ b/index.php Wed Oct 22 01:12:55 2014 +0900 @@ -42,7 +42,14 @@ // BEGIN UTILITY function h($string) { return htmlspecialchars($string, ENT_QUOTES, "UTF-8"); } function a($string) { return preg_replace("#(%2F)+#", "/", rawurlencode($string)); } - function link_to($target, $title) { return('' . h($title) . ""); } + function link_to($target, $title) { + $lightbox = ""; + if (substr($target, -1) !== "/" && preg_match("/(jpe?g|gif|png|webp)$/i", pathinfo($target, PATHINFO_EXTENSION)) === 1) { + $lightbox = ' data-lightbox="aa" '; + } + + return('" . h($title) . ""); + } function human_size($size) { $thousand_units = array("ko", "Mo", "Go", "To", "Po"); @@ -119,6 +126,7 @@ Index of <?php echo h($prefix . $path); ?> +