2012-01-04, 06:27:45
OK, got it working perfectly.
The function "insert_javascript_and_css" does what it says.
It copies the content of the meta.php file and adds it into the <head></head>.
(jquery lightbox and css)
The code validates and the page looks exactly like I wanted it to look
Thanks guys!
Code:
<?php if(!defined('IN_GS')){ die('you cannot load this page directly.'); }
/*
* @File: functions.php
* @Action: SG theme
*/
add_action('theme-header','insert_javascript_and_css');
function insert_javascript_and_css () {
$lines = file("theme/Sg/files/meta.php");
foreach ($lines as $line_num => $line)
{echo $line;}
}
function nQaG($gallery_dir,$folder){
$alldir = $gallery_dir."/".$folder."/";
$tndir = $gallery_dir."/".$folder."/tn/";
if (!is_dir($tndir)) {mkdir($tndir);}
//$images = glob("/tmp/*.{jpeg,gif,png}", GLOB_BRACE);
$img_count = count(glob($alldir."*.{jpg,JPG,jpeg,JPEG}",GLOB_BRACE));
$tn_count = count(glob($tndir."*.{jpg,JPG,jpeg,JPEG}",GLOB_BRACE));
$img_dir_list = glob($alldir."*.{jpg,JPG,jpeg,JPEG}",GLOB_BRACE);
sort($img_dir_list);
if ($tn_count < $img_count)
{
//create thumbnails
$dir_handle = opendir($alldir);
foreach($img_dir_list as $imagefile)
{
//if (!file_exists($tndir.$imagefile)){
$onlyfile = str_replace($alldir, "", $imagefile);
$img = imagecreatefromjpeg($alldir.$onlyfile);
$width = imagesx($img);
$height = imagesy($img);
$tn_width = 200;
$new_height = ceil($tn_width * ($height / $width));
$tmp = imagecreatetruecolor($tn_width, $new_height);
imagecopyresized($tmp,$img,0,0,0,0,$tn_width,$new_height,$width,$height);
//imagejpeg($tmp,"$tndir".$tnfile,100);print_r ($tmp."<br />");
imagejpeg($tmp, $tndir.$onlyfile);
//}
}
}
// Create and Open the new php file
$createIndex = "$alldir"."index.php";
$fh = fopen($createIndex, 'w') or die("can't open file");
// Get the content from the template
$stringData = "<div id=\"gallery\">\n<ul>\n";
fwrite($fh, $stringData);
foreach($img_dir_list as $imglink){
$links = str_replace($alldir, "", $imglink);
fwrite($fh,"<li><a title=\"$gallery_dir\" href=\"../$alldir$links\" ><img class=\"shadows\" src=\"../$tndir$links\" alt=\"$gallery_dir\" /></a></li>\n");
}
$stringData = "</ul>\n</div>";
fwrite($fh, $stringData);
fclose($fh);
include ($alldir."index.php");
}
?>
The function "insert_javascript_and_css" does what it says.
It copies the content of the meta.php file and adds it into the <head></head>.
(jquery lightbox and css)
The code validates and the page looks exactly like I wanted it to look
Thanks guys!