make keeping avatar versions an option in the ACP that is turned off by default

v1.18.x
Ben Lubar 9 years ago
parent 0d40542f93
commit fc387111e2

@ -25,6 +25,7 @@ module.exports = function(User) {
var updateUid = uid;
var imageDimension = parseInt(meta.config.profileImageDimension, 10) || 128;
var convertToPNG = parseInt(meta.config['profile:convertProfileImageToPNG'], 10) === 1;
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
var uploadedImage;
async.waterfall([
@ -42,7 +43,7 @@ module.exports = function(User) {
return plugins.fireHook('filter:uploadImage', {image: picture, uid: updateUid}, next);
}
var filename = updateUid + '-profileimg-' + Date.now() + (convertToPNG ? '.png' : extension);
var filename = updateUid + '-profileimg' + (keepAllVersions ? '-' + Date.now() : '') + (convertToPNG ? '.png' : extension);
async.waterfall([
function(next) {
@ -120,6 +121,7 @@ module.exports = function(User) {
};
User.updateCoverPicture = function(data, callback) {
var keepAllVersions = parseInt(meta.config['profile:keepAllUserImages'], 10) === 1;
var url, md5sum;
if (!data.imageData && data.position) {
@ -167,7 +169,7 @@ module.exports = function(User) {
return plugins.fireHook('filter:uploadImage', {image: image, uid: data.uid}, next);
}
var filename = data.uid + '-profilecover-' + Date.now();
var filename = data.uid + '-profilecover' + (keepAllVersions ? '-' + Date.now() : '');
async.waterfall([
function (next) {
file.isFileTypeAllowed(data.file.path, next);

@ -115,6 +115,13 @@
(in kilobytes, default: 2,048 KiB)
</p>
</div>
<div class="checkbox">
<label class="mdl-switch mdl-js-switch mdl-js-ripple-effect">
<input class="mdl-switch__input" type="checkbox" data-field="profile:keepAllUserImages">
<span class="mdl-switch__label"><strong>Keep old versions of avatars and profile covers on the server</strong></span>
</label>
</div>
</form>
</div>
</div>
@ -132,4 +139,4 @@
</div>
</div>
<!-- IMPORT admin/settings/footer.tpl -->
<!-- IMPORT admin/settings/footer.tpl -->

Loading…
Cancel
Save