Adjusted graphic extension settings

This commit is contained in:
Matthew Barbour 2019-06-18 13:55:18 -05:00 committed by matthew
parent 3859e27839
commit e98e63f836

View File

@ -167,41 +167,37 @@ class Graphics extends Extension
{ {
global $config; global $config;
$config->set_default_string(GraphicsConfig::FFPROBE_PATH, 'ffprobe'); $config->set_default_string(GraphicsConfig::FFPROBE_PATH, 'ffprobe');
$config->set_default_int(GraphicsConfig::MEM_LIMIT, parse_shorthand_int('8MB'));
$config->set_default_string(GraphicsConfig::FFMPEG_PATH, '');
$config->set_default_string(GraphicsConfig::CONVERT_PATH, '');
if ($config->get_int(GraphicsConfig::VERSION) < 1) { if ($config->get_int(GraphicsConfig::VERSION) < 1) {
$current_value = $config->get_string("thumb_ffmpeg_path"); $current_value = $config->get_string("thumb_ffmpeg_path");
if(!empty($current_value)) { if (!empty($current_value)) {
$config->set_string(GraphicsConfig::FFMPEG_PATH, $current_value); $config->set_string(GraphicsConfig::FFMPEG_PATH, $current_value);
} elseif ($ffmpeg = shell_exec((PHP_OS == 'WINNT' ? 'where' : 'which') . ' ffmpeg')) { } elseif ($ffmpeg = shell_exec((PHP_OS == 'WINNT' ? 'where' : 'which') . ' ffmpeg')) {
//ffmpeg exists in PATH, check if it's executable, and if so, default to it instead of static //ffmpeg exists in PATH, check if it's executable, and if so, default to it instead of static
if (is_executable(strtok($ffmpeg, PHP_EOL))) { if (is_executable(strtok($ffmpeg, PHP_EOL))) {
$config->set_default_string(GraphicsConfig::FFMPEG_PATH, 'ffmpeg'); $config->set_default_string(GraphicsConfig::FFMPEG_PATH, 'ffmpeg');
} }
} else {
$config->set_default_string(GraphicsConfig::FFMPEG_PATH, '');
} }
$current_value = $config->get_string("thumb_convert_path"); $current_value = $config->get_string("thumb_convert_path");
if(!empty($current_value)) { if (!empty($current_value)) {
$config->set_string(GraphicsConfig::CONVERT_PATH, $current_value); $config->set_string(GraphicsConfig::CONVERT_PATH, $current_value);
} elseif ($convert = shell_exec((PHP_OS == 'WINNT' ? 'where' : 'which') . ' convert')) { } elseif ($convert = shell_exec((PHP_OS == 'WINNT' ? 'where' : 'which') . ' convert')) {
//ffmpeg exists in PATH, check if it's executable, and if so, default to it instead of static //ffmpeg exists in PATH, check if it's executable, and if so, default to it instead of static
if (is_executable(strtok($convert, PHP_EOL))) { if (is_executable(strtok($convert, PHP_EOL))) {
$config->set_default_string(GraphicsConfig::CONVERT_PATH, 'convert'); $config->set_default_string(GraphicsConfig::CONVERT_PATH, 'convert');
} }
} else {
$config->set_default_string(GraphicsConfig::CONVERT_PATH, '');
} }
$current_value = $config->get_int("thumb_mem_limit"); $current_value = $config->get_int("thumb_mem_limit");
if(!empty($current_value)) { if (!empty($current_value)) {
$config->set_int(GraphicsConfig::MEM_LIMIT, $current_value); $config->set_int(GraphicsConfig::MEM_LIMIT, $current_value);
} }
$config->set_int(GraphicsConfig::VERSION, 1); $config->set_int(GraphicsConfig::VERSION, 1);
log_info("graphics", "extension installed"); log_info("graphics", "extension installed");
} }