Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provider::small generates files into Settings::$small_dir #371

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/classes/AdminStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function Calculate() {

$this->stats['Items'] = sizeof(Menu::list_files(Settings::$photos_dir,true));

$this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir,true));
$this->stats['Generated items'] = sizeof(Menu::list_files(Settings::$thumbs_dir,true)) + sizeof(Menu::list_files(Settings::$small_dir,true));

$this->stats['Albums'] = sizeof(Menu::list_dirs(Settings::$photos_dir,true));

Expand Down
6 changes: 1 addition & 5 deletions src/classes/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,12 @@ public static function small($file)
{
require_once dirname(__FILE__).'/../phpthumb/phpthumb.class.php';

$basefile = new File($file);
$basepath = File::a2r($file);
$webimg = dirname($basepath) . "/" . $basefile->name . "_small." . $basefile->extension;

list($x,$y) = getimagesize($file);
if($x <= 1200 && $y <= 1200){
return $file;
}

$path = File::r2a($webimg, Settings::$thumbs_dir);
$path = File::r2a(File::a2r($file),Settings::$small_dir);

/// Create smaller image
if (!file_exists($path) || filectime($file) > filectime($path)) {
Expand Down
10 changes: 10 additions & 0 deletions src/classes/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Settings extends Page
/// Directory where the thumbs are stored
static public $thumbs_dir;

/// Directory where the small images are stored
static public $small_dir;

/// Directory where the configuration files are stored
static public $conf_dir;

Expand Down Expand Up @@ -212,6 +215,7 @@ static public function init($forced = false, $config_file = NULL){
/// Setup variables
Settings::$photos_dir = $config->photos_dir;
Settings::$thumbs_dir = $config->ps_generated."/Thumbs/";
Settings::$small_dir = $config->ps_generated."/Small/";
Settings::$conf_dir = $config->ps_generated."/Conf/";
Settings::$admin_settings_file = $config->ps_generated."/Conf/admin_settings.ini";

Expand Down Expand Up @@ -255,6 +259,12 @@ static public function init($forced = false, $config_file = NULL){
}
}

if(!file_exists(Settings::$small_dir)){
if(! @mkdir(Settings::$small_dir,0750,true)){
throw new Exception("PS_GENERATED dir '".Settings::$small_dir."' doesn't exist or doesn't have the good rights.");
}
}

if(!file_exists(Settings::$conf_dir)){
if(! @mkdir(Settings::$conf_dir,0750,true)){
throw new Exception("PS_GENERATED dir '".Settings::$conf_dir."' doesn't exist or doesn't have the good rights.");
Expand Down