diff options
Diffstat (limited to '')
-rw-r--r-- | admin/include/functions_upload.inc.php | 39 | ||||
-rw-r--r-- | admin/photos_add.php | 37 | ||||
-rw-r--r-- | admin/photos_add_settings.php | 62 | ||||
-rw-r--r-- | admin/themes/default/template/photos_add_settings.tpl | 67 |
4 files changed, 182 insertions, 23 deletions
diff --git a/admin/include/functions_upload.inc.php b/admin/include/functions_upload.inc.php index d3716948a..7eaeb90f5 100644 --- a/admin/include/functions_upload.inc.php +++ b/admin/include/functions_upload.inc.php @@ -84,6 +84,33 @@ function add_uploaded_file($source_filepath, $original_filename=null, $categorie $conf['upload_form_websize_quality'], false ); + + if (is_imagick()) + { + if ($conf['upload_form_hd_keep']) + { + $need_resize = need_resize($high_path, $conf['upload_form_hd_maxwidth'], $conf['upload_form_hd_maxheight']); + + if ($conf['upload_form_hd_resize'] and $need_resize) + { + pwg_image_resize( + false, + $high_path, + $high_path, + $conf['upload_form_hd_maxwidth'], + $conf['upload_form_hd_maxheight'], + $conf['upload_form_hd_quality'], + false + ); + $high_infos = pwg_image_infos($high_path); + } + } + else + { + unlink($high_path); + $high_infos = null; + } + } } $file_infos = pwg_image_infos($file_path); @@ -250,7 +277,7 @@ function pwg_image_resize($result, $source_filepath, $destination_filepath, $max return $result; } - if (extension_loaded('imagick')) + if (is_imagick()) { return pwg_image_resize_im($source_filepath, $destination_filepath, $max_width, $max_height, $quality, $strip_metadata); } @@ -520,4 +547,14 @@ function add_upload_error($upload_id, $error_message) array_push($_SESSION['uploads_error'][$upload_id], $error_message); } + +function is_imagick() +{ + if (extension_loaded('imagick')) + { + return true; + } + + return false; +} ?>
\ No newline at end of file diff --git a/admin/photos_add.php b/admin/photos_add.php index 54db3113c..889395985 100644 --- a/admin/photos_add.php +++ b/admin/photos_add.php @@ -103,6 +103,43 @@ $upload_form_config = array( 'can_be_null' => false, 'error_message' => l10n('The thumbnail image quality must be a number between %d and %d'), ), + + 'hd_keep' => array( + 'default' => true, + 'can_be_null' => false, + ), + + 'hd_resize' => array( + 'default' => false, + 'can_be_null' => false, + ), + + 'hd_maxwidth' => array( + 'default' => 2000, + 'min' => 500, + 'max' => 20000, + 'pattern' => '/^\d+$/', + 'can_be_null' => false, + 'error_message' => l10n('The high definition maximum width must be a number between %d and %d'), + ), + + 'hd_maxheight' => array( + 'default' => 2000, + 'min' => 500, + 'max' => 20000, + 'pattern' => '/^\d+$/', + 'can_be_null' => false, + 'error_message' => l10n('The high definition maximum height must be a number between %d and %d'), + ), + + 'hd_quality' => array( + 'default' => 95, + 'min' => 50, + 'max' => 100, + 'pattern' => '/^\d+$/', + 'can_be_null' => false, + 'error_message' => l10n('The high definition image quality must be a number between %d and %d'), + ), ); $inserts = array(); diff --git a/admin/photos_add_settings.php b/admin/photos_add_settings.php index 1b3f28d1b..0edaa3919 100644 --- a/admin/photos_add_settings.php +++ b/admin/photos_add_settings.php @@ -45,26 +45,32 @@ if (isset($_POST['submit'])) // let's care about the specific checkbox that disable/enable other // settings $field = 'websize_resize'; + $fields[] = $field; - if (empty($_POST[$field])) - { - $value = false; - } - else + if (!empty($_POST[$field])) { $fields[] = 'websize_maxwidth'; $fields[] = 'websize_maxheight'; $fields[] = 'websize_quality'; + } - $value = true; + // hd_keep + $field = 'hd_keep'; + $fields[] = $field; + + if (!empty($_POST[$field])) + { + $field = 'hd_resize'; + $fields[] = $field; + + if (!empty($_POST[$field])) + { + $fields[] = 'hd_maxwidth'; + $fields[] = 'hd_maxheight'; + $fields[] = 'hd_quality'; + } } - $updates[] = array( - 'param' => 'upload_form_'.$field, - 'value' => boolean_to_string($value), - ); - $form_values[$field] = $value;; - // and now other fields, processed in a generic way $fields[] = 'thumb_maxwidth'; $fields[] = 'thumb_maxheight'; @@ -77,9 +83,24 @@ if (isset($_POST['submit'])) { $value = $_POST[$field]; } - $form_values[$field] = $value; - if ($upload_form_config[$field]['can_be_null'] and empty($value)) + if (is_bool($upload_form_config[$field]['default'])) + { + if (isset($value)) + { + $value = true; + } + else + { + $value = false; + } + + $updates[] = array( + 'param' => 'upload_form_'.$field, + 'value' => boolean_to_string($value) + ); + } + elseif ($upload_form_config[$field]['can_be_null'] and empty($value)) { $updates[] = array( 'param' => 'upload_form_'.$field, @@ -111,6 +132,8 @@ if (isset($_POST['submit'])) ); } } + + $form_values[$field] = $value; } if (count($page['errors']) == 0) @@ -135,13 +158,18 @@ if (isset($_POST['submit'])) // | template init | // +-----------------------------------------------------------------------+ -// specific case, "websize_resize" is a checkbox -$field = 'websize_resize'; -$form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; +foreach (array_keys($upload_form_config) as $field) +{ + if (is_bool($upload_form_config[$field]['default'])) + { + $form_values[$field] = $form_values[$field] ? 'checked="checked"' : ''; + } +} $template->assign( array( 'F_ADD_ACTION'=> PHOTOS_ADD_BASE_URL, + 'MANAGE_HD' => is_imagick(), 'values' => $form_values ) ); diff --git a/admin/themes/default/template/photos_add_settings.tpl b/admin/themes/default/template/photos_add_settings.tpl index d4fb74400..fe9830e9e 100644 --- a/admin/themes/default/template/photos_add_settings.tpl +++ b/admin/themes/default/template/photos_add_settings.tpl @@ -1,20 +1,48 @@ {literal} <script type="text/javascript"> $(document).ready(function(){ - function toggleResizeFields() { - var checkbox = $("#websize_resize"); - var needToggle = $("input[name^=websize_]").not(checkbox).parents('tr'); + function toggleResizeFields(prefix) { + var checkbox = $("#"+prefix+"_resize"); + var needToggle = $("input[name^="+prefix+"_]").not(checkbox).not($("#hd_keep")).parents('tr'); + if ($(checkbox).is(':checked')) { needToggle.show(); + + if (prefix == "websize") { + $("#hd_keep").parents("fieldset").show(); + } } else { needToggle.hide(); + + if (prefix == "websize") { + $("#hd_keep").parents("fieldset").hide(); + } } } - toggleResizeFields(); - $("#websize_resize").click(function () {toggleResizeFields()}); + toggleResizeFields("websize"); + $("#websize_resize").click(function () {toggleResizeFields("websize")}); + + toggleResizeFields("hd"); + $("#hd_resize").click(function () {toggleResizeFields("hd")}); + + function toggleHdFields() { + var checkbox = $("#hd_keep"); + var needToggle = $("input[name^=hd_]").not(checkbox).parents('tr'); + + if ($(checkbox).is(':checked')) { + needToggle.show(); + toggleResizeFields("hd"); + } + else { + needToggle.hide(); + } + } + + toggleHdFields(); + $("#hd_keep").click(function () {toggleHdFields()}); }); </script> {/literal} @@ -69,6 +97,35 @@ $(document).ready(function(){ </table> </fieldset> +{if $MANAGE_HD} + <fieldset> + <legend>{'High definition'|@translate}</legend> + + <table> + <tr> + <th><label for="hd_keep">{'Keep high definition'|@translate}</label></th> + <td><input type="checkbox" name="hd_keep" id="hd_keep" {$values.hd_keep}></td> + </tr> + <tr> + <th><label for="hd_resize">{'Resize'|@translate}</label></th> + <td><input type="checkbox" name="hd_resize" id="hd_resize" {$values.hd_resize}></td> + </tr> + <tr> + <th>{'Maximum Width'|@translate}</th> + <td><input type="text" name="hd_maxwidth" value="{$values.hd_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td> + </tr> + <tr> + <th>{'Maximum Height'|@translate}</th> + <td><input type="text" name="hd_maxheight" value="{$values.hd_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td> + </tr> + <tr> + <th>{'Image Quality'|@translate}</th> + <td><input type="text" name="hd_quality" value="{$values.hd_quality}" size="3" maxlength="3"> %</td> + </tr> + </table> + </fieldset> +{/if} + <p> <input class="submit" type="submit" name="submit" value="{'Save Settings'|@translate}"/> </p> |