feature:2259
Add "Regenerate Websize Photos" action. git-svn-id: http://piwigo.org/svn/trunk@10454 68402e56-0260-453c-a942-63ccdbb3a9ee
This commit is contained in:
parent
b58846ff7b
commit
f7bc47d1f6
3 changed files with 129 additions and 60 deletions
|
|
@ -43,6 +43,12 @@ foreach ($upload_form_config as $param_shortname => $param)
|
||||||
$form_values[$param_shortname] = $conf[$param_name];
|
$form_values[$param_shortname] = $conf[$param_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// User cache must not be regenerated during simultaneous ajax requests
|
||||||
|
if (!isset($user['need_update']) or !$user['need_update'])
|
||||||
|
{
|
||||||
|
getuserdata($user['id'], true);
|
||||||
|
}
|
||||||
|
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
// | Check Access and exit when user status is not ok |
|
// | Check Access and exit when user status is not ok |
|
||||||
// +-----------------------------------------------------------------------+
|
// +-----------------------------------------------------------------------+
|
||||||
|
|
@ -409,12 +415,27 @@ SELECT id, path
|
||||||
array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess']));
|
array_push($page['infos'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateSuccess']));
|
||||||
|
|
||||||
if ($_POST['regenerateError'] != '0')
|
if ($_POST['regenerateError'] != '0')
|
||||||
array_push($page['warnings'], sprintf(l10n('%s thumbnails have been regenerated'), $_POST['regenerateError']));
|
array_push($page['warnings'], sprintf(l10n('%s thumbnails can not be regenerated'), $_POST['regenerateError']));
|
||||||
|
|
||||||
|
$update_fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('regenerateWebsize' == $action)
|
||||||
|
{
|
||||||
|
if ($_POST['regenerateSuccess'] != '0')
|
||||||
|
array_push($page['infos'], sprintf(l10n('%s photos have been regenerated'), $_POST['regenerateSuccess']));
|
||||||
|
|
||||||
|
if ($_POST['regenerateError'] != '0')
|
||||||
|
array_push($page['warnings'], sprintf(l10n('%s photos can not be regenerated'), $_POST['regenerateError']));
|
||||||
|
|
||||||
|
$update_fields = array('websize_maxwidth', 'websize_maxheight', 'websize_quality');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($update_fields))
|
||||||
|
{
|
||||||
// Update configuration
|
// Update configuration
|
||||||
$fields = array('thumb_maxwidth', 'thumb_maxheight', 'thumb_quality');
|
|
||||||
$updates = array();
|
$updates = array();
|
||||||
foreach ($fields as $field)
|
foreach ($update_fields as $field)
|
||||||
{
|
{
|
||||||
$value = null;
|
$value = null;
|
||||||
if (!empty($_POST[$field]))
|
if (!empty($_POST[$field]))
|
||||||
|
|
@ -450,11 +471,6 @@ SELECT id, path
|
||||||
$updates
|
$updates
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
function regenerateThumbnails_prefilter($content, $smarty)
|
|
||||||
{
|
|
||||||
return str_replace('{$thumbnail.TN_SRC}', '{$thumbnail.TN_SRC}?rand='.md5(uniqid(rand(), true)), $content);
|
|
||||||
}
|
|
||||||
$template->set_prefilter('batch_manager_global', 'regenerateThumbnails_prefilter');
|
|
||||||
$template->delete_compiled_templates();
|
$template->delete_compiled_templates();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -783,6 +799,12 @@ $template->assign(
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
function regenerateThumbnails_prefilter($content, $smarty)
|
||||||
|
{
|
||||||
|
return str_replace('{$thumbnail.TN_SRC}', '{$thumbnail.TN_SRC}?rand='.md5(uniqid(rand(), true)), $content);
|
||||||
|
}
|
||||||
|
$template->set_prefilter('batch_manager_global', 'regenerateThumbnails_prefilter');
|
||||||
|
|
||||||
trigger_action('loc_end_element_set_global');
|
trigger_action('loc_end_element_set_global');
|
||||||
|
|
||||||
//----------------------------------------------------------- sending html code
|
//----------------------------------------------------------- sending html code
|
||||||
|
|
|
||||||
|
|
@ -35,13 +35,8 @@ var selectedMessage_pattern = "{'%d of %d photos selected'|@translate}";
|
||||||
var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
|
var selectedMessage_none = "{'No photo selected, %d photos in current set'|@translate}";
|
||||||
var selectedMessage_all = "{'All %d photos are selected'|@translate}";
|
var selectedMessage_all = "{'All %d photos are selected'|@translate}";
|
||||||
var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
|
var regenerateThumbnailsMessage = "{'Thumbnails generation in progress...'|@translate}";
|
||||||
|
var regenerateWebsizeMessage = "{'Photos generation in progress...'|@translate}";
|
||||||
{literal}
|
{literal}
|
||||||
var queuedManagerThumbnails = $.manageAjax.create('queued', {
|
|
||||||
queue: true,
|
|
||||||
cacheResponse: false,
|
|
||||||
maxRequests: 3
|
|
||||||
});
|
|
||||||
|
|
||||||
function str_repeat(i, m) {
|
function str_repeat(i, m) {
|
||||||
for (var o = []; m > 0; o[--m] = i);
|
for (var o = []; m > 0; o[--m] = i);
|
||||||
return o.join('');
|
return o.join('');
|
||||||
|
|
@ -327,55 +322,78 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
jQuery('#applyAction').click(function() {
|
jQuery('#applyAction').click(function() {
|
||||||
if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails') {
|
if (elements.length != 0)
|
||||||
if (elements.length != 0)
|
{
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
if (jQuery('input[name="setSelected"]').attr('checked'))
|
else if (jQuery('[name="selectAction"]').val() == 'regenerateThumbnails')
|
||||||
elements = all_elements;
|
{
|
||||||
else
|
type = 'thumbnail';
|
||||||
jQuery('input[name="selection[]"]').each(function() {
|
maxRequests = 3;
|
||||||
if (jQuery(this).attr('checked')) {
|
|
||||||
elements.push(jQuery(this).val());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
|
maxwidth = jQuery('input[name="thumb_maxwidth"]').val();
|
||||||
maxheight = jQuery('input[name="thumb_maxheight"]').val();
|
maxheight = jQuery('input[name="thumb_maxheight"]').val();
|
||||||
progressBar_max = elements.length;
|
regenerationText = regenerateThumbnailsMessage;
|
||||||
todo = 0;
|
}
|
||||||
|
else if(jQuery('[name="selectAction"]').val() == 'regenerateWebsize')
|
||||||
|
{
|
||||||
|
type = 'websize';
|
||||||
|
maxRequests = 1;
|
||||||
|
maxwidth = jQuery('input[name="websize_maxwidth"]').val();
|
||||||
|
maxheight = jQuery('input[name="websize_maxheight"]').val();
|
||||||
|
regenerationText = regenerateWebsizeMessage;
|
||||||
|
}
|
||||||
|
else return true;
|
||||||
|
|
||||||
jQuery('#thumb_config').hide();
|
jQuery('.bulkAction').hide();
|
||||||
jQuery('#applyActionBlock').hide();
|
jQuery('#regenerationText').html(regenerationText);
|
||||||
jQuery('select[name="selectAction"]').hide();
|
|
||||||
jQuery('#regenerationMsg').show();
|
var queuedManager = jQuery.manageAjax.create('queued', {
|
||||||
jQuery('#regenerationText').html(regenerateThumbnailsMessage);
|
queue: true,
|
||||||
jQuery('#progressBar').progressBar(0, {
|
cacheResponse: false,
|
||||||
max: progressBar_max,
|
maxRequests: maxRequests
|
||||||
textFormat: 'fraction',
|
});
|
||||||
boxImage: 'themes/default/images/progressbar.gif',
|
|
||||||
barImage: 'themes/default/images/progressbg_orange.gif'
|
if (jQuery('input[name="setSelected"]').attr('checked'))
|
||||||
|
elements = all_elements;
|
||||||
|
else
|
||||||
|
jQuery('input[name="selection[]"]').each(function() {
|
||||||
|
if (jQuery(this).attr('checked')) {
|
||||||
|
elements.push(jQuery(this).val());
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
for (i=0;i<elements.length;i++) {
|
progressBar_max = elements.length;
|
||||||
queuedManagerThumbnails.add({
|
todo = 0;
|
||||||
type: 'GET',
|
|
||||||
url: 'ws.php',
|
jQuery('#applyActionBlock').hide();
|
||||||
data: {
|
jQuery('select[name="selectAction"]').hide();
|
||||||
method: 'pwg.images.resize',
|
jQuery('#regenerationMsg').show();
|
||||||
type: 'thumbnail',
|
|
||||||
maxwidth: maxwidth,
|
jQuery('#progressBar').progressBar(0, {
|
||||||
maxheight: maxheight,
|
max: progressBar_max,
|
||||||
image_id: elements[i],
|
textFormat: 'fraction',
|
||||||
format: 'json'
|
boxImage: 'themes/default/images/progressbar.gif',
|
||||||
},
|
barImage: 'themes/default/images/progressbg_orange.gif'
|
||||||
dataType: 'json',
|
});
|
||||||
success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
|
|
||||||
error: ( function(data) { progress(++todo, progressBar_max, false) })
|
for (i=0;i<elements.length;i++) {
|
||||||
});
|
queuedManager.add({
|
||||||
}
|
type: 'GET',
|
||||||
return false;
|
url: 'ws.php',
|
||||||
|
data: {
|
||||||
|
method: 'pwg.images.resize',
|
||||||
|
type: type,
|
||||||
|
maxwidth: maxwidth,
|
||||||
|
maxheight: maxheight,
|
||||||
|
image_id: elements[i],
|
||||||
|
format: 'json'
|
||||||
|
},
|
||||||
|
dataType: 'json',
|
||||||
|
success: ( function(data) { progress(++todo, progressBar_max, data['result']) }),
|
||||||
|
error: ( function(data) { progress(++todo, progressBar_max, false) })
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
checkPermitAction()
|
checkPermitAction()
|
||||||
|
|
@ -552,6 +570,7 @@ jQuery(window).load(function() {
|
||||||
<option value="add_to_caddie">{'add to caddie'|@translate}</option>
|
<option value="add_to_caddie">{'add to caddie'|@translate}</option>
|
||||||
{/if}
|
{/if}
|
||||||
<option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>
|
<option value="regenerateThumbnails">{'Regenerate Thumbnails'|@translate}</option>
|
||||||
|
<option value="regenerateWebsize">{'Regenerate Websize Photos'|@translate}</option>
|
||||||
{if !empty($element_set_global_plugins_actions)}
|
{if !empty($element_set_global_plugins_actions)}
|
||||||
{foreach from=$element_set_global_plugins_actions item=action}
|
{foreach from=$element_set_global_plugins_actions item=action}
|
||||||
<option value="{$action.ID}">{$action.NAME}</option>
|
<option value="{$action.ID}">{$action.NAME}</option>
|
||||||
|
|
@ -640,7 +659,7 @@ jQuery(window).load(function() {
|
||||||
|
|
||||||
<!-- regenerate thumbnails -->
|
<!-- regenerate thumbnails -->
|
||||||
<div id="action_regenerateThumbnails" class="bulkAction">
|
<div id="action_regenerateThumbnails" class="bulkAction">
|
||||||
<table style="margin-left:20px;" id="thumb_config">
|
<table style="margin-left:20px;">
|
||||||
<tr>
|
<tr>
|
||||||
<th>{'Maximum Width'|@translate}</th>
|
<th>{'Maximum Width'|@translate}</th>
|
||||||
<td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
<td><input type="text" name="thumb_maxwidth" value="{$upload_form_settings.thumb_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||||
|
|
@ -656,8 +675,31 @@ jQuery(window).load(function() {
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- regenerate websize -->
|
||||||
|
<div id="action_regenerateWebsize" class="bulkAction">
|
||||||
|
<p>
|
||||||
|
<img src="admin/themes/default/icon/warning.png" alt="!" style="vertical-align:middle;">
|
||||||
|
{'Only photos with HD can be regenerated!'|@translate}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table style="margin:10px 20px;">
|
||||||
|
<tr>
|
||||||
|
<th>{'Maximum Width'|@translate}</th>
|
||||||
|
<td><input type="text" name="websize_maxwidth" value="{$upload_form_settings.websize_maxwidth}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{'Maximum Height'|@translate}</th>
|
||||||
|
<td><input type="text" name="websize_maxheight" value="{$upload_form_settings.websize_maxheight}" size="4" maxlength="4"> {'pixels'|@translate}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>{'Image Quality'|@translate}</th>
|
||||||
|
<td><input type="text" name="websize_quality" value="{$upload_form_settings.websize_quality}" size="3" maxlength="3"> %</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- progress bar -->
|
<!-- progress bar -->
|
||||||
<div id="regenerationMsg" style="display:none;">
|
<div id="regenerationMsg" class="bulkAction">
|
||||||
<p id="regenerationText" style="margin-bottom:10px;"></p>
|
<p id="regenerationText" style="margin-bottom:10px;"></p>
|
||||||
<span class="progressBar" id="progressBar"></span>
|
<span class="progressBar" id="progressBar"></span>
|
||||||
<input type="hidden" name="regenerateSuccess" value="0">
|
<input type="hidden" name="regenerateSuccess" value="0">
|
||||||
|
|
|
||||||
|
|
@ -2726,6 +2726,11 @@ WHERE id = '.(int)$params['image_id'].'
|
||||||
$params['quality'],
|
$params['quality'],
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$conf['use_exif'] = false;
|
||||||
|
$conf['use_iptc'] = false;
|
||||||
|
update_metadata(array($image['id'] => $image['path']));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue