/** * @param $folder * @param $url * @param $options * @return bool */ public function makeThumb($folder, $url, $options) { if (empty($url)) { return false; } $thumb = new \Helpers\PHPThumb(); $inputFile = MODX_BASE_PATH . $this->fs->relativePath($url); $outputFile = MODX_BASE_PATH . $this->fs->relativePath($folder) . '/' . $this->fs->relativePath($url); $dir = $this->fs->takeFileDir($outputFile); $this->fs->makeDir($dir, $this->modx->config['new_folder_permissions']); if ($thumb->create($inputFile, $outputFile, $options)) { return true; } else { $this->modx->logEvent(0, 3, $thumb->debugMessages, __NAMESPACE__); return false; } }
if ($thumb['rid'] == $rid || $thumb['template'] == $template) { $out = $thumb; break; } } return $out; } } if ($e->name == "OnFileBrowserUpload" && isset($template) || $e->name == "OnSimpleGalleryRefresh") { $thumb = new \Helpers\PHPThumb(); $thumb->optimize($filepath . '/' . $filename); $fs = \Helpers\FS::getInstance(); $thumbConfig = getThumbConfig($tconfig, $sg_rid, $template); if (!empty($thumbConfig)) { extract($thumbConfig); $fs->makeDir($filepath . '/' . $folder); $thumb->create($filepath . '/' . $filename, $filepath . '/' . $folder . '/' . $filename, $options); $thumb->optimize($filepath . '/' . $folder . '/' . $filename); } } if ($e->name == "OnSimpleGalleryDelete") { $fs = \Helpers\FS::getInstance(); $thumbConfig = getThumbConfig($tconfig, $sg_rid, $template); if (!empty($thumbConfig)) { extract($thumbConfig); $file = $filepath . '/' . $folder . '/' . $filename; if (file_exists($file)) { unlink($file); } } }