
$input = "pathtoimage/image.jpg";
$width = 200;
$height = 50;
$options = "w=$width&height=$height&zc=1";
$thumbnail = $modx->runSnippet("phpthumbof",array('input' => $input, 'options' => $options));
<?php
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"type" => filetype("$dir$entry"),
"size" => 0,
"lastmod" => filemtime("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"type" => mime_content_type("$dir$entry"),
"size" => filesize("$dir$entry"),
"lastmod" => filemtime("$dir$entry")
);
}
}
$d->close();
return $retval;
}
$dirGal = "assets/galeria/".$nomGal;
$dirlist = getFileList($dirGal);
echo "<div id='galslide' class='nivoSlider'>";
foreach($dirlist as $file) {
if(!preg_match("/\.jpg$/", $file['name'])) continue;
// echo "<img src='".$file['name']."'/>";
$input = $file['name'];
$width = 50;
$height = 50;
$options = "w=$width&height=$height&zc=1";
$thumbnail = $modx->runSnippet("phpthumbof",array('input' => $input, 'options' => $options));
echo "<img src='".$input."' rel='".$thumbnail."'/>";
}
echo "</div>";
Hi Eminos
I think to use the runSnippet method should work.
Try out the following.
$input = "pathtoimage/image.jpg"; $width = 200; $height = 50; $options = "w=$width&height=$height&zc=1"; $thumbnail = $modx->runSnippet("phpthumbof",array('input' => $input, 'options' => $options));
The variable $thumbnail should now containing the path to your thumbnail image.
I didn't test the code...
Cheers