Archived
1
0
Fork 0

don't use DIRECTORY_SEPARATOR for URL paths (fixes #58)

This commit is contained in:
Jan Dittberner 2009-07-15 21:32:11 +00:00
parent 050caa5830
commit a165f02bea

View file

@ -237,20 +237,19 @@ function getScaledImage($galleryname, $basename, $maxdim, $scaleheight=true) {
} }
$gallerydir = realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . $galleryname); $gallerydir = realpath($configuration['gallerydir'] . DIRECTORY_SEPARATOR . $galleryname);
if ($scaleheight) { if ($scaleheight) {
$scaleddir = sprintf("%s%sscaled_x%d", $galleryname, $scaleddir = sprintf("scaled_x%d", $maxdim);
DIRECTORY_SEPARATOR, $maxdim);
} else { } else {
$scaleddir = sprintf("%s%sscaled%dx_", $galleryname, $scaleddir = sprintf("scaled%dx_", $maxdim);
DIRECTORY_SEPARATOR, $maxdim);
} }
$scaleddirpath = $configuration['gallerydir'] . DIRECTORY_SEPARATOR . $scaleddir; $scaleddirpath = implode(DIRECTORY_SEPARATOR,
array($configuration['gallerydir'], $galleryname, $scaleddir));
if (!is_dir($scaleddirpath)) { if (!is_dir($scaleddirpath)) {
// versuchen das Thumbnail-Verzeichnis anzulegen // versuchen das Thumbnail-Verzeichnis anzulegen
$mkdir = @mkdir($scaleddirpath, 0755); $mkdir = @mkdir($scaleddirpath, 0755);
if (!$mkdir) { if (!$mkdir) {
trigger_error("could not create directory $scaleddirpath.\n", trigger_error("could not create directory $scaleddirpath.\n",
E_USER_WARNING); E_USER_WARNING);
return $galleryname . DIRECTORY_SEPARATOR . $basename; return $galleryname . '/' . $basename;
} }
} }
@ -275,7 +274,7 @@ function getScaledImage($galleryname, $basename, $maxdim, $scaleheight=true) {
$origx, $origy); $origx, $origy);
imagejpeg($newimage, $scaledimage, 90); imagejpeg($newimage, $scaledimage, 90);
} }
return $scaleddir . DIRECTORY_SEPARATOR . $basename; return implode('/', array($galleryname, $scaleddir, $basename));
} }
/** /**
@ -377,7 +376,7 @@ function getAllThumbnails(&$thumbinfo) {
$retval = array(); $retval = array();
foreach ($thumbinfo[2] as $basename => $data) { foreach ($thumbinfo[2] as $basename => $data) {
$retval[] = array('src' => $configuration['gallerypath'] . DIRECTORY_SEPARATOR . $data[0], $retval[] = array('src' => $configuration['gallerypath'] . '/' . $data[0],
'sizes' => $data[1][3], 'sizes' => $data[1][3],
'alt' => getImageLabel($thumbinfo[1], $basename)); 'alt' => getImageLabel($thumbinfo[1], $basename));
} }
@ -405,8 +404,7 @@ function getFirstPreview(&$thumbinfo) {
$basename = key($thumbinfo[2]); $basename = key($thumbinfo[2]);
$data = current($thumbinfo[2]); $data = current($thumbinfo[2]);
$galleryname = $thumbinfo[1]; $galleryname = $thumbinfo[1];
$fullname = $configuration['gallerypath'] . DIRECTORY_SEPARATOR . $galleryname . $fullname = $configuration['gallerypath'] . '/' . $galleryname . '/' . $basename;
DIRECTORY_SEPARATOR . $basename;
$scaledimage = getScaledImage($galleryname, $basename, $scaledimage = getScaledImage($galleryname, $basename,
$theme->previewsize, false); $theme->previewsize, false);
$scaledimagesize = getimagesize(realpath($configuration['gallerydir'] . $scaledimagesize = getimagesize(realpath($configuration['gallerydir'] .
@ -415,7 +413,7 @@ function getFirstPreview(&$thumbinfo) {
$label = getImageLabel($galleryname, $basename); $label = getImageLabel($galleryname, $basename);
return array('title' => $label, return array('title' => $label,
'full' => $fullname, 'full' => $fullname,
'src' => $configuration['gallerypath'] . DIRECTORY_SEPARATOR . $scaledimage, 'src' => $configuration['gallerypath'] . '/' . $scaledimage,
'alt' => $label, 'alt' => $label,
'sizes' => $scaledimagesize[3]); 'sizes' => $scaledimagesize[3]);
} }