From 8e098d502a8f0e413b9c085db27d6a62a6c0909f Mon Sep 17 00:00:00 2001 From: plegall Date: Thu, 3 Dec 2015 16:04:02 +0100 Subject: feature #379 multiple format, step 1: add formats * new table piwigo_image_format (each photo can have 0 to many formats) * only compatible with synchronization for now. Formats must be in sub-directory pwg_format * formats are visible on edition page only for now --- include/config_default.inc.php | 4 ++++ include/constants.php | 2 ++ include/functions.inc.php | 15 +++++++++++++++ 3 files changed, 21 insertions(+) (limited to 'include') diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 60a3da323..ec0b58522 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -63,6 +63,10 @@ $conf['file_ext'] = array_merge( array('tiff', 'tif', 'mpg','zip','avi','mp3','ogg','pdf') ); +// format_ext : file extensions for formats, ie additional versions of a +// photo (or nay other file). Formats are in sub-directory pwg_format. +$conf['format_ext'] = array('cr2', 'tif', 'tiff', 'nef', 'dng', 'ai'); + // top_number : number of element to display for "best rated" and "most // visited" categories $conf['top_number'] = 15; diff --git a/include/constants.php b/include/constants.php index 83d8747bc..ef321a4bc 100644 --- a/include/constants.php +++ b/include/constants.php @@ -105,5 +105,7 @@ if (!defined('THEMES_TABLE')) define('THEMES_TABLE', $prefixeTable.'themes'); if (!defined('LANGUAGES_TABLE')) define('LANGUAGES_TABLE', $prefixeTable.'languages'); +if (!defined('IMAGE_FORMAT_TABLE')) + define('IMAGE_FORMAT_TABLE', $prefixeTable.'image_format'); ?> diff --git a/include/functions.inc.php b/include/functions.inc.php index 60a1885e5..e1658c31f 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -952,6 +952,21 @@ function original_to_representative($path, $representative_ext) return substr_replace($path, $representative_ext, $pos+1); } +/** + * Transforms an original path to its format + * + * @param string $path + * @param string $format_ext + * @return string + */ +function original_to_format($path, $format_ext) +{ + $pos = strrpos($path, '/'); + $path = substr_replace($path, 'pwg_format/', $pos+1, 0); + $pos = strrpos($path, '.'); + return substr_replace($path, $format_ext, $pos+1); +} + /** * get the full path of an image * -- cgit v1.2.3 From c3b748ecbfd1a359f6e95e7fd691ac5c11c3c4de Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 7 Dec 2015 10:54:18 +0100 Subject: feature #379 multiple format, step 2: download formats * if formats are available, replace the download link on picture.php by a switchBox with all formats * register format in the history table for future statistics --- include/functions.inc.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/functions.inc.php b/include/functions.inc.php index e1658c31f..2119abe8f 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -407,7 +407,7 @@ SELECT id, name * @param string $image_type * @return bool */ -function pwg_log($image_id = null, $image_type = null) +function pwg_log($image_id = null, $image_type = null, $format_id = null) { global $conf, $user, $page; @@ -445,6 +445,7 @@ INSERT INTO '.HISTORY_TABLE.' category_id, image_id, image_type, + format_id, tag_ids ) VALUES @@ -457,6 +458,7 @@ INSERT INTO '.HISTORY_TABLE.' '.(isset($page['category']['id']) ? $page['category']['id'] : 'NULL').', '.(isset($image_id) ? $image_id : 'NULL').', '.(isset($image_type) ? "'".$image_type."'" : 'NULL').', + '.(isset($format_id) ? $format_id : 'NULL').', '.(isset($tags_string) ? "'".$tags_string."'" : 'NULL').' ) ;'; -- cgit v1.2.3 From ca238de66d4b6801c4cd817c27effcf18a211da2 Mon Sep 17 00:00:00 2001 From: plegall Date: Wed, 16 Dec 2015 18:16:16 +0100 Subject: feature #379 multiple format, step 3: add/remove * during sync, Piwigo will detect new/removed formats for an existing photo * multiple formats features is disabled by default --- include/config_default.inc.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/config_default.inc.php b/include/config_default.inc.php index ec0b58522..dc8a47183 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -63,6 +63,9 @@ $conf['file_ext'] = array_merge( array('tiff', 'tif', 'mpg','zip','avi','mp3','ogg','pdf') ); +// enable_formats: should Piwigo search for multiple formats? +$conf['enable_formats'] = false; + // format_ext : file extensions for formats, ie additional versions of a // photo (or nay other file). Formats are in sub-directory pwg_format. $conf['format_ext'] = array('cr2', 'tif', 'tiff', 'nef', 'dng', 'ai'); -- cgit v1.2.3 From 6e2a4495bfa576fc1c08ed1ec586d6eb4a4ad5d8 Mon Sep 17 00:00:00 2001 From: plegall Date: Sun, 20 Dec 2015 21:00:28 +0100 Subject: feature #379, multiple format, add psd file extension by default --- include/config_default.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/config_default.inc.php b/include/config_default.inc.php index dc8a47183..eafb9d5a9 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -68,7 +68,7 @@ $conf['enable_formats'] = false; // format_ext : file extensions for formats, ie additional versions of a // photo (or nay other file). Formats are in sub-directory pwg_format. -$conf['format_ext'] = array('cr2', 'tif', 'tiff', 'nef', 'dng', 'ai'); +$conf['format_ext'] = array('cr2', 'tif', 'tiff', 'nef', 'dng', 'ai', 'psd'); // top_number : number of element to display for "best rated" and "most // visited" categories -- cgit v1.2.3