Changeset 10553 for trunk


Ignore:
Timestamp:
Apr 22, 2011, 12:35:16 AM (14 years ago)
Author:
patdenice
Message:

feature:2273
Add crop functionality to webservice and batch manager.

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/batch_manager_global.php

    r10454 r10553  
    418418      array_push($page['warnings'], sprintf(l10n('%s thumbnails can not be regenerated'), $_POST['regenerateError']));
    419419
    420     $update_fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality');
     420    $update_fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality', 'thumb_crop', 'thumb_follow_orientation');
    421421  }
    422422
     
    438438    foreach ($update_fields as $field)
    439439    {
    440       $value = null;
    441       if (!empty($_POST[$field]))
     440      if (is_bool($upload_form_config[$field]['default']))
    442441      {
    443         $value = $_POST[$field];
    444       }
    445 
    446       if (preg_match($upload_form_config[$field]['pattern'], $value)
    447         and $value >= $upload_form_config[$field]['min']
    448         and $value <= $upload_form_config[$field]['max'])
    449       {
    450         $conf['upload_form_'.$field] = $value;
    451          $updates[] = array(
     442        $value = isset($_POST[$field]);
     443
     444        $updates[] = array(
    452445          'param' => 'upload_form_'.$field,
    453           'value' => $value
     446          'value' => boolean_to_string($value)
    454447          );
    455448      }
    456449      else
    457450      {
    458         $updates = null;
    459         break;
     451        $value = null;
     452        if (!empty($_POST[$field]))
     453        {
     454          $value = $_POST[$field];
     455        }
     456
     457        if (preg_match($upload_form_config[$field]['pattern'], $value)
     458          and $value >= $upload_form_config[$field]['min']
     459          and $value <= $upload_form_config[$field]['max'])
     460        {
     461          $conf['upload_form_'.$field] = $value;
     462           $updates[] = array(
     463            'param' => 'upload_form_'.$field,
     464            'value' => $value
     465            );
     466        }
     467        else
     468        {
     469          $updates = null;
     470          break;
     471        }
    460472      }
    461473      $form_values[$field] = $value;
  • trunk/admin/themes/default/template/batch_manager_global.tpl

    r10454 r10553  
    3737var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
    3838var regenerateWebsizeMessage = "{'Photos generation in progress...'|@translate}";
     39
     40var width_str = '{'Width'|@translate}';
     41var height_str = '{'Height'|@translate}';
     42var max_width_str = '{'Maximum Width'|@translate}';
     43var max_height_str = '{'Maximum Height'|@translate}';
    3944{literal}
    4045function str_repeat(i, m) {
     
    334339      maxheight = jQuery('input[name="thumb_maxheight"]').val();
    335340      regenerationText = regenerateThumbnailsMessage;
     341      crop = jQuery('input[name="thumb_crop"]').is(':checked');
     342      follow_orientation = jQuery('input[name="thumb_follow_orientation"]').is(':checked');
    336343    }
    337344    else if(jQuery('[name="selectAction"]').val() == 'regenerateWebsize')
     
    342349      maxheight = jQuery('input[name="websize_maxheight"]').val();
    343350      regenerationText = regenerateWebsizeMessage;
     351      crop = false;
     352      follow_orientation = false;
    344353    }
    345354    else return true;
     
    386395          maxwidth: maxwidth,
    387396          maxheight: maxheight,
     397          crop: crop,
     398          follow_orientation: follow_orientation,
    388399          image_id: elements[i],
    389400          format: 'json'
     
    396407    return false;
    397408  });
     409
     410  function toggleCropFields(prefix) {
     411    if (jQuery("#"+prefix+"_crop").is(':checked')) {
     412      jQuery("#"+prefix+"_width_th").text(width_str);
     413      jQuery("#"+prefix+"_height_th").text(height_str);
     414      jQuery("#"+prefix+"_follow_orientation_tr").show();
     415    }
     416    else {
     417      jQuery("#"+prefix+"_width_th").text(max_width_str);
     418      jQuery("#"+prefix+"_height_th").text(max_height_str);
     419      jQuery("#"+prefix+"_follow_orientation_tr").hide();
     420    }
     421  }
     422
     423  toggleCropFields("thumb");
     424  jQuery("#thumb_crop").click(function () {toggleCropFields("thumb")});
    398425
    399426  checkPermitAction()
     
    662689      <table style="margin-left:20px;">
    663690        <tr>
    664           <th>{'Maximum Width'|@translate}</th>
     691          <th><label for="thumb_crop">{'Crop'|@translate}</label></th>
     692          <td><input type="checkbox" name="thumb_crop" id="thumb_crop" {if $upload_form_settings.thumb_crop}checked="checked"{/if}></td>
     693        </tr>
     694        <tr id="thumb_follow_orientation_tr">
     695          <th><label for="thumb_follow_orientation">{'Follow Orientation'|@translate}</label></th>
     696          <td><input type="checkbox" name="thumb_follow_orientation" id="thumb_follow_orientation" {if $upload_form_settings.thumb_follow_orientation}checked="checked"{/if}></td>
     697        </tr>
     698        <tr>
     699          <th id="thumb_width_th">{'Maximum Width'|@translate}</th>
    665700          <td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
    666701        </tr>
    667702        <tr>
    668           <th>{'Maximum Height'|@translate}</th>
     703          <th id="thumb_height_th">{'Maximum Height'|@translate}</th>
    669704          <td><input type="text" name="thumb_maxheight" value="{$upload_form_settings.thumb_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
    670705        </tr>
  • trunk/include/ws_functions.inc.php

    r10538 r10553  
    26742674  }
    26752675
    2676   $resize_params = array('maxwidth', 'maxheight', 'quality');
     2676  $resize_params = array('maxwidth', 'maxheight', 'quality', 'crop', 'follow_orientation');
    26772677  $type = $params['type'] == 'thumbnail' ? 'thumb' : 'websize';
    26782678  foreach ($resize_params as $param)
    26792679  {
    2680     if (empty($params[$param]))
     2680    if (empty($params[$param]) and isset($conf['upload_form_'.$type.'_'.$param]))
    26812681      $params[$param] = $conf['upload_form_'.$type.'_'.$param];
    26822682  }
     
    27112711      $params['maxheight'],
    27122712      $params['quality'],
    2713       true
     2713      true,
     2714      get_boolean($params['crop']),
     2715      get_boolean($params['follow_orientation'])
    27142716    );
    27152717    return true;
  • trunk/ws.php

    r10538 r10553  
    413413      'maxwidth' => array('default' => null),
    414414      'maxheight' => array('default' => null),
     415      'crop' => array('default' => null),
     416      'follow_orientation' => array('default' => null),
    415417      'quality' => array('default' => null),
    416418    ),
    417419    'Regenerate thumbnails or websize photo with given arguments.
    418420<br>Argument "type" can be "thumbnail" or "websize". Default is "thumbnail".
    419 <br>If maxwidth, maxheight or quality are missing, default parameters of upload will be used.'
     421<br>If maxwidth, maxheight, crop, follow_orientation or quality are missing, default parameters of upload will be used.'
    420422);
    421423
Note: See TracChangeset for help on using the changeset viewer.