It looks like you're new here. If you want to get involved, click one of these buttons!
<div class="FilePreview"><?php
$Path = GetValue('Path', $Media);
$imageSize = getimagesize(PATH_UPLOADS.'/'.$Path);
if ($imageSize) {
if ($imageSize[0] > 200 || $imageSize[1] > 200) {
$pathInfo = pathinfo($Path);
// Get dimensions of thumb
$thumbDimensions = array('height' => $imageSize[1], 'width' => $imageSize[0]);
if ($thumbDimensions['height'] > 200) {
$thumbDimensions['height'] = 200;
$thumbDimensions['width'] = intval(($thumbDimensions['width']) * ($thumbDimensions['height'] / $imageSize[1]));
}
if ($thumbDimensions['width'] > 200) {
$thumbDimensions['width'] = 200;
$thumbDimensions['height'] = intval($imageSize[1] * ($thumbDimensions['width'] / $imageSize[0]));
}
$thumbPath = $pathInfo['dirname'].'/'.$pathInfo['filename'].'_'.$thumbDimensions['width'].'x'.$thumbDimensions['height'].'.'.$pathInfo['extension'];
if (file_exists(PATH_UPLOADS.'/'.$thumbPath)) {
$Path = $thumbPath;
}
else {
try {
if (!class_exists('PhpThumbFactory')) {
include(realpath(dirname(__FILE__).'/../../phpThumb/ThumbLib.inc.php'));
}
$thumb = PhpThumbFactory::create(PATH_UPLOADS.'/'.$Path);
$thumb->resize($thumbDimensions['width'], $thumbDimensions['height']);
$thumb->save(PATH_UPLOADS.'/'.$thumbPath, $pathInfo['extension']);
$Path = $thumbPath;
}
catch (Exception $e) { }
}
}
echo Img('uploads/'.$Path, array('class' => 'ImageThumbnail'));
}
else
echo Img('plugins/FileUpload/images/paperclip.png', array('class' => 'ImageThumbnail'));
?></div>
Comments
- Spam
- Abuse
- Troll
0 • Off Topic Insightful Awesome LOL •