Skip to content

Commit

Permalink
v1.4.6
Browse files Browse the repository at this point in the history
- Changed Determining the image file size.
- Fixed Submit buttons after closing the confirm box without function.
  • Loading branch information
IMC-GER committed Jul 15, 2024
1 parent 4b53937 commit 7101759
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio

## Changelog

### v1.4.6 (14-07-2024)
- Changed Determining the image file size.
- Fixed Submit buttons after closing the confirm box without function.

### v1.4.5 (23-06-2024)
- Fixed Some servers do not send the new file size after uploading images.

Expand Down
4 changes: 4 additions & 0 deletions imcger/imgupload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio

## Changelog

### v1.4.6 (14-07-2024)
- Changed Determining the image file size.
- Fixed Submit buttons after closing the confirm box without function.

### v1.4.5 (23-06-2024)
- Fixed Some servers do not send the new file size after uploading images.

Expand Down
4 changes: 2 additions & 2 deletions imcger/imgupload/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"type": "phpbb-extension",
"description": "Using ImageMagick php librarie for resize image attachments and creating thumbnails.",
"homepage": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
"version": "1.4.5-pl1",
"time": "2024-06-23",
"version": "1.4.6",
"time": "2024-07-14",
"license": "GPL-2.0-only",
"authors": [
{
Expand Down
10 changes: 7 additions & 3 deletions imcger/imgupload/controller/ajax_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,13 @@ private function image_size($attach_id)

$file_path = join('/', [trim($this->config['upload_path'], '/'), trim($img_data['physical_filename'], '/')]);

$image = new \Imagick($file_path);
$filesize = strlen($image->getImageBlob());
$image->clear();
clearstatcache();
$filesize = @filesize($file_path);

if ($filesize == false)
{
$this->json_response(5);
}

$this->json_response(0, $this->ext_display_name, '', $attach_id, $attach_id, $filesize);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@
*/
imcger.imgUpload = {};

/**
* Remove new click event in 3.3.12
* It doesn't work with imgUpload,
* the event function is built into imgUpload own event.
*/
$('[data-prevent-flood] input[type=submit]').off('click');

/**
* Update row with new attachment id
* when save image after rotate
Expand Down Expand Up @@ -449,10 +456,14 @@
* and rotated images have not been saved
*/
$('.submit-buttons').on('click', '.button1', function(e) {
imcger.imgUpload.submitType = $(e.target).attr('name');
imcger.imgUpload.submitButton = $(this); // Store the button element

let attach_id = 0,
imgHTMLList = '<ul>';

// Always add the disabled class for visual feedback
imcger.imgUpload.submitButton.addClass('disabled');

// Are all images saved?
$.each(imcger.imgUpload.image.imgOrientationValue, function(index, value) {

Expand All @@ -470,6 +481,27 @@

e.preventDefault();
phpbb.confirm(confirmMsgText, imcger.imgUpload.confirmSavePost, true);

// Re-enable when the confirmbox is closed by clicking on the wrapper
$('#darken').on('click', function(e) {imcger.imgUpload.submitButton.removeClass('disabled');});

} else {
const $form = imcger.imgUpload.submitButton.closest('form');

// Submit form if it hasn't been submitted yet
if (!$form.prop('data-form-submitted')) {
$form.prop('data-form-submitted', true);

return;
}

// Prevent default submission for subsequent clicks within 5 seconds
e.preventDefault();

setTimeout(() => {
$form.prop('removeProp', 'data-form-submitted');
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds
}, 5000);
}
});

Expand All @@ -488,7 +520,26 @@
}

$('.submit-buttons').off('click', '.button1');
$('.submit-buttons [name="' + imcger.imgUpload.submitType + '"').trigger('click');
imcger.imgUpload.submitButton.trigger('click');

const $form = imcger.imgUpload.submitButton.closest('form');

// Submit form if it hasn't been submitted yet
if (!$form.prop('data-form-submitted')) {
$form.prop('data-form-submitted', true);

return;
}

// Prevent default submission for subsequent clicks within 5 seconds
e.preventDefault();

setTimeout(() => {
$form.prop('removeProp', 'data-form-submitted');
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds
}, 5000);
} else {
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable
}
}

Expand Down
2 changes: 1 addition & 1 deletion imgupload_version.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"stable": {
"1.0": {
"current": "1.4.5-pl1",
"current": "1.4.6",
"announcement": "https://www.phpbb.de/community/viewtopic.php?t=246009",
"download": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
"eol": null,
Expand Down

0 comments on commit 7101759

Please sign in to comment.