Skip to content

Commit 7101759

Browse files
committed
v1.4.6
- Changed Determining the image file size. - Fixed Submit buttons after closing the confirm box without function.
1 parent 4b53937 commit 7101759

File tree

6 files changed

+71
-8
lines changed

6 files changed

+71
-8
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio
5454

5555
## Changelog
5656

57+
### v1.4.6 (14-07-2024)
58+
- Changed Determining the image file size.
59+
- Fixed Submit buttons after closing the confirm box without function.
60+
5761
### v1.4.5 (23-06-2024)
5862
- Fixed Some servers do not send the new file size after uploading images.
5963

imcger/imgupload/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ For full functionality "Maximum avatar file size" in "ACP" > "Board configuratio
5454

5555
## Changelog
5656

57+
### v1.4.6 (14-07-2024)
58+
- Changed Determining the image file size.
59+
- Fixed Submit buttons after closing the confirm box without function.
60+
5761
### v1.4.5 (23-06-2024)
5862
- Fixed Some servers do not send the new file size after uploading images.
5963

imcger/imgupload/composer.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"type": "phpbb-extension",
44
"description": "Using ImageMagick php librarie for resize image attachments and creating thumbnails.",
55
"homepage": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
6-
"version": "1.4.5-pl1",
7-
"time": "2024-06-23",
6+
"version": "1.4.6",
7+
"time": "2024-07-14",
88
"license": "GPL-2.0-only",
99
"authors": [
1010
{

imcger/imgupload/controller/ajax_controller.php

+7-3
Original file line numberDiff line numberDiff line change
@@ -241,9 +241,13 @@ private function image_size($attach_id)
241241

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

244-
$image = new \Imagick($file_path);
245-
$filesize = strlen($image->getImageBlob());
246-
$image->clear();
244+
clearstatcache();
245+
$filesize = @filesize($file_path);
246+
247+
if ($filesize == false)
248+
{
249+
$this->json_response(5);
250+
}
247251

248252
$this->json_response(0, $this->ext_display_name, '', $attach_id, $attach_id, $filesize);
249253
}

imcger/imgupload/styles/all/template/event/overall_footer_body_after.html

+53-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@
2525
*/
2626
imcger.imgUpload = {};
2727

28+
/**
29+
* Remove new click event in 3.3.12
30+
* It doesn't work with imgUpload,
31+
* the event function is built into imgUpload own event.
32+
*/
33+
$('[data-prevent-flood] input[type=submit]').off('click');
34+
2835
/**
2936
* Update row with new attachment id
3037
* when save image after rotate
@@ -449,10 +456,14 @@
449456
* and rotated images have not been saved
450457
*/
451458
$('.submit-buttons').on('click', '.button1', function(e) {
452-
imcger.imgUpload.submitType = $(e.target).attr('name');
459+
imcger.imgUpload.submitButton = $(this); // Store the button element
460+
453461
let attach_id = 0,
454462
imgHTMLList = '<ul>';
455463

464+
// Always add the disabled class for visual feedback
465+
imcger.imgUpload.submitButton.addClass('disabled');
466+
456467
// Are all images saved?
457468
$.each(imcger.imgUpload.image.imgOrientationValue, function(index, value) {
458469

@@ -470,6 +481,27 @@
470481

471482
e.preventDefault();
472483
phpbb.confirm(confirmMsgText, imcger.imgUpload.confirmSavePost, true);
484+
485+
// Re-enable when the confirmbox is closed by clicking on the wrapper
486+
$('#darken').on('click', function(e) {imcger.imgUpload.submitButton.removeClass('disabled');});
487+
488+
} else {
489+
const $form = imcger.imgUpload.submitButton.closest('form');
490+
491+
// Submit form if it hasn't been submitted yet
492+
if (!$form.prop('data-form-submitted')) {
493+
$form.prop('data-form-submitted', true);
494+
495+
return;
496+
}
497+
498+
// Prevent default submission for subsequent clicks within 5 seconds
499+
e.preventDefault();
500+
501+
setTimeout(() => {
502+
$form.prop('removeProp', 'data-form-submitted');
503+
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds
504+
}, 5000);
473505
}
474506
});
475507

@@ -488,7 +520,26 @@
488520
}
489521

490522
$('.submit-buttons').off('click', '.button1');
491-
$('.submit-buttons [name="' + imcger.imgUpload.submitType + '"').trigger('click');
523+
imcger.imgUpload.submitButton.trigger('click');
524+
525+
const $form = imcger.imgUpload.submitButton.closest('form');
526+
527+
// Submit form if it hasn't been submitted yet
528+
if (!$form.prop('data-form-submitted')) {
529+
$form.prop('data-form-submitted', true);
530+
531+
return;
532+
}
533+
534+
// Prevent default submission for subsequent clicks within 5 seconds
535+
e.preventDefault();
536+
537+
setTimeout(() => {
538+
$form.prop('removeProp', 'data-form-submitted');
539+
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable after 5 seconds
540+
}, 5000);
541+
} else {
542+
imcger.imgUpload.submitButton.removeClass('disabled'); // Re-enable
492543
}
493544
}
494545

imgupload_version.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"stable": {
33
"1.0": {
4-
"current": "1.4.5-pl1",
4+
"current": "1.4.6",
55
"announcement": "https://www.phpbb.de/community/viewtopic.php?t=246009",
66
"download": "https://github.com/IMC-GER/phpBB-Image-upload-use-ImageMagick/tags",
77
"eol": null,

0 commit comments

Comments
 (0)