Mei Coobi...
Ich habe die Lightbox Gallery ein bischen angepasst da in der "normalen" Version die Thumbnails nur skaliert werden und keine Möglichkeit besteht die skalierten auch noch zu beschneiden.
In meiner Anpassung hab ich die Skalierungfunktion belassen und zusätzlich eine Beschneidungsfunktion eingefügt die auch über das Backend konfigurierbar ist.
Die Bilder können jetzt nach der skalierung auf genau die Größe zugeschnitten werden damit alle Thumbnails die selbe Größe haben, völlig egal ob das Seitenverhältnis unterschiedlich ist.
Man sollte nur darauf achten dass die Skalierung nicht kleiner skaliert als die Beschneidung das Bild beschneiden will...
Code: Alles auswählen
<?php
cInclude("includes", "functions.api.images.php");
/* Gallery variables */
$bRecursive = false;
/* Input variables customized */
$iWidth_crop = "CMS_VALUE[7]";
$iHeight_crop = "CMS_VALUE[8]";
if ($iWidth_crop == 0) {
$iWidth_crop = '';
}
if ($iHeight_crop == 0) {
$iHeight_crop = '';
}
/* Cropping ? */
$iCrop = "CMS_VALUE[9]";
/* Input variables */
$iWidth = "CMS_VALUE[0]";
$iHeight = "CMS_VALUE[1]";
if ($iWidth == 0) {
$iWidth = 300;
}
if ($iHeight == 0) {
$iHeight = 300;
}
$iColumns = "CMS_VALUE[2]";
if ($iColumns == 0) {
$iColumns = 2;
}
$iRows = "CMS_VALUE[3]";
if ($iRows == 0) {
$iRows = 2;
}
$sPath = "CMS_VALUE[4]";
if ($sPath=='') {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "bildergalerie/";
} else {
$sPath = $cfgClient[$client]["path"]["frontend"] . $cfgClient[$client]["upl"]["frontendpath"] . "CMS_VALUE[4]";
}
$sort = "CMS_VALUE[5]";
if( $sort == "asc" ) {
$sort = SORT_ASC;
} else {
$sort = SORT_DESC;
}
$words = "CMS_VALUE[6]";
if (isset($start)) {
$iCurrentPage = $start;
} else {
$iCurrentPage = 1;
}
$aValidExtensions = array("jpg", "jpeg", "gif", "png");
$iImagesPerPage = $iRows * $iColumns;
/* Read all gallery files */
$aGalleryFiles = scanDirectory($sPath, $bRecursive);
array_multisort($aGalleryFiles, $sort, SORT_STRING);
if (is_array($aGalleryFiles)) {
/* Filter out non-images */
foreach ($aGalleryFiles as $key => $aGalleryFile) {
$sExtension = strtolower(getFileExtension($aGalleryFile));
if (!in_array($sExtension, $aValidExtensions)) {
unset($aGalleryFiles[$key]);
}
}
/* Calculate effective variables */
$iFileCount = count($aGalleryFiles);
$iPages = ceil($iFileCount / $iImagesPerPage);
$aImagesToDisplay = array_slice($aGalleryFiles, ($iCurrentPage - 1) * $iImagesPerPage, $iImagesPerPage);
$oImageTpl = new Template;
$oGalleryTpl = new Template;
$oEmptyImageTpl = new Template;
$aRenderedImages = array();
$iRow = 0;
$iImagesRendered = 0;
foreach ($aImagesToDisplay as $sImageToDisplay) {
/* Do Scaling */
/* ### Customized - changes by GaMbIt ### */
/* Image scale */
$sScaledImage_cr = cApiImgScale($sImageToDisplay, $iWidth, $iHeight, false, false);
/* path */
$sScaledImage_cr = str_replace($cfgClient[$client]["path"]["htmlpath"],"",$sScaledImage_cr);
/* Image crop */
$sScaledImage = cApiImgScale($sScaledImage_cr, $iWidth_crop, $iHeight_crop, true, true);
/* path */
$sScaledImage = str_replace($cfgClient[$client]["path"]["htmlpath"],"",$sScaledImage);
/* ### End custom changes by GaMbIt ### */
$link = str_replace($cfgClient[$client]['path']['frontend'],$cfgClient['htmlpath'],$sImageToDisplay);
$media_name = ig_getMedienName($sImageToDisplay);
$link_description = ig_getImageDescription($sImageToDisplay);
if ($words != "" || $words != 0) {
# Cutting text but preserving words and entities
if(strlen($link_description) > $words){
$description = htmlentities(capiStrTrimAfterWord($link_description, $words)."...");
} else {
$description = "";
}
}
if( $media_name != "" && $link_description != "") {
$link_description = $media_name.': '.$link_description;
} elseif( $media_name != "" ) {
$link_description = $link_description;
} elseif( $description != "" ) {
$link_description = $link_description;
$media_name = " ";
}
$oImageTpl->reset();
$oImageTpl->set("s", "FILE", $sScaledImage);
$oImageTpl->set("s", "WIDTH", $iWidth);
$oImageTpl->set("s", "HEIGHT", $iHeight);
$oImageTpl->set("s", "LINK", $link);
$oImageTpl->set("s", "MEDIANAME", $media_name);
$oImageTpl->set("s", "DESCRIPTION", $description);
$oImageTpl->set("s", "LINKDESCRIPTION", $link_description);
$aRenderedImages[] = $oImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_image.html", true, false);
$iImagesRendered++;
if ($iImagesRendered == $iColumns) {
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages));
$oGalleryTpl->next();
$iImagesRendered = 0;
$aRenderedImages = array();
}
}
if (count($aRenderedImages) < $iColumns && count($aRenderedImages) > 0) {
$iEmptyCells = $iColumns - count($aRenderedImages);
$oEmptyImageTpl->set("s", "WIDTH", $iWidth);
$oEmptyImageTpl->set("s", "HEIGHT", $iHeight);
$sEmptyCells = str_repeat($oEmptyImageTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_empty.html", true, false),$iEmptyCells);
$oGalleryTpl->set("d", "COLUMNS", implode("", $aRenderedImages) . $sEmptyCells);
$oGalleryTpl->next();
}
$aLinks = array();
if ($iCurrentPage > 1) {
$oPreviousTpl = new Template;
$oPreviousTpl->set("s", "LINK", $cfgClient[$client]["path"]["htmlpath"] . sprintf("front_content.php?idcatart=%s&start=%s", $idcatart, $iCurrentPage - 1));
$oPreviousTpl->set("s", "TITLE", mi18n("Zurück"));
$aLinks[] = $oPreviousTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_link.html", true, false);
}
if (($iCurrentPage < $iPages) && $iCurrentPage) {
$oNextTpl = new Template;
$oNextTpl->set("s", "LINK", $cfgClient[$client]["path"]["htmlpath"] . sprintf("front_content.php?idcatart=%s&start=%s", $idcatart, $iCurrentPage + 1));
$oNextTpl->set("s", "TITLE", mi18n("Vor"));
$aLinks[] = $oNextTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery_link.html", true, false);
}
$oGalleryTpl->set("s", "NAVIGATION", implode("", $aLinks));
$oGalleryTpl->generate($cfgClient[$client]["path"]["frontend"] . "templates/lightbox-gallery.html", false, false);
}
function ig_getImageDescription($idupl){
global $cfg, $cfgClient, $db, $client, $lang;
$cApiClient = new cApiClient($client);
$language_separator = $cApiClient->getProperty('language','separator');
if ($language_separator == "") {
//Sanity, if module used in client without set client setting
$language_separator = "§§§";
$cApiClient->setProperty('language','separator', $language_separator);
}
if(is_numeric($idupl)) {
//ID is a number
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE idupl = ".$idupl;
} else {
//ID is a string
$path_parts = pathinfo($idupl);
$upload = $cfgClient[$client]['upl']['frontendpath'];
$len = strlen($upload);
$pos = strpos($idupl,$upload);
$dirname = substr($path_parts['dirname'],$pos+$len).'/';
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE (dirname = '".$dirname."') AND (filename='".$path_parts['basename']."') AND (filetype='".$path_parts['extension']."')";
}
$db->query($query);
if($db->next_record()) {
return htmlspecialchars(urldecode($db->f("description")));
} else {
return '';
}
}
function ig_getMedienName($idupl) {
global $cfg, $cfgClient, $db, $client, $lang;
$cApiClient = new cApiClient($client);
$language_separator = $cApiClient->getProperty('language','separator');
if ($language_separator == "") {
//Sanity, if module used in client without set client setting
$language_separator = "§§§";
$cApiClient->setProperty('language','separator', $language_separator);
}
if( is_numeric($idupl) ) {
//ID is a number
$query = "SELECT description FROM ".$cfg["tab"]["upl"]." WHERE idupl = ".$idupl;
} else {
//ID is a string
$path_parts = pathinfo($idupl);
$upload = $cfgClient[$client]['upl']['frontendpath'];
$len = strlen($upload);
$pos = strpos($idupl,$upload);
$dirname = substr($path_parts['dirname'],$pos+$len).'/';
$danis = $dirname.$path_parts['basename'];
$query = "SELECT value FROM ".$cfg["tab"]["properties"]." WHERE itemid = '".$dirname.$path_parts['basename']."' AND name = 'medianame'";
}
$db->query($query);
if( $db->next_record() ) {
return htmlspecialchars(urldecode($db->f("value")));
} else {
return '';
}
}
?>
Ich schick dem Poster von diesem Modul mal die exportierte XML weil da auch noch die Beschreibungen in der Übersetzung enthalten ist.