[PR #4578] [MERGED] Improvements to file/image upload handling UX #6379

Closed
opened 2026-02-05 10:30:45 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/4578
Author: @ssddanbrown
Created: 9/25/2023
Status: Merged
Merged: 10/1/2023
Merged by: @ssddanbrown

Base: developmentHead: upload_handling


📝 Commits (10+)

  • 59da766 Uploads: Added user-facing message for Laravel post limit handling
  • cc0827f Images: Updated to create thumbnails at specific events
  • 5af3041 Thumbnails: Added OOM handling and regen endpoint
  • 5c318a4 Images: Reverted some thumbnails to be on-demand generated
  • 97274a8 Images: Added test to cover thubmnail regen endpoint
  • 4072143 Image manager: Tweaked grid sizing to prevent massive items
  • 7247e31 Images: Started refactor of image service
  • e703009 Images: Added thin wrapper around image filesystem instances
  • 20bcbd7 Images: Extracted out image resizing to its own class
  • b2d48d9 Images: Rolled out image memory handling to image actions

📊 Changes

29 files changed (+854 additions, -525 deletions)

View changed files

📝 app/Entities/Models/Book.php (+4 -11)
📝 app/Entities/Models/Bookshelf.php (+7 -13)
📝 app/Entities/Tools/ExportFormatter.php (+1 -1)
📝 app/Exceptions/Handler.php (+41 -1)
📝 app/Uploads/Controllers/DrawioImageController.php (+18 -9)
📝 app/Uploads/Controllers/GalleryImageController.php (+21 -4)
📝 app/Uploads/Controllers/ImageController.php (+43 -14)
📝 app/Uploads/Controllers/ImageGalleryApiController.php (+5 -2)
📝 app/Uploads/Image.php (+4 -3)
📝 app/Uploads/ImageRepo.php (+10 -39)
app/Uploads/ImageResizer.php (+206 -0)
📝 app/Uploads/ImageService.php (+39 -415)
app/Uploads/ImageStorage.php (+136 -0)
app/Uploads/ImageStorageDisk.php (+140 -0)
📝 app/Users/Models/User.php (+1 -1)
app/Util/OutOfMemoryHandler.php (+58 -0)
📝 lang/en/components.php (+2 -0)
📝 lang/en/errors.php (+4 -0)
📝 resources/js/components/image-manager.js (+30 -5)
📝 resources/js/markdown/actions.js (+2 -2)

...and 9 more files

📄 Description

Related to #4454.

  • Adds friendlier handling, with proper message, for requests caught by Laravel's ValidatePostSize middleware.
  • Refactors and splits out much of the image file handling.

Todo

  • Roll out OOM handling to other endpoints where thumbs are created
    • Roll out to gallery responses, so images are created via these means but the original view is still returned if an OOM occurance happens. Needs juggling of view and thumbnail gen.
      • Drawings
      • Images
  • Test new thumbnail regen endpoint
  • Fix large thumbnails when image manager only has single/few images in list.

Notes

  • See Illuminate\Foundation\Bootstrap\HandleExceptions for example of reserving memory and handling errors (via register_shutdown_function). Can run custom hook through register_shutdown_function. Need to test conflicts with Laravel's own handling.
  • Need to consider for API also.

Screenshots

Preview of added image manager handling:

Screenshot 2023-10-01 at 12-54-46 Editing Page Comment testing The BookStack


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/4578 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 9/25/2023 **Status:** ✅ Merged **Merged:** 10/1/2023 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `upload_handling` --- ### 📝 Commits (10+) - [`59da766`](https://github.com/BookStackApp/BookStack/commit/59da7666b5773a9b7063185d7585ed664d351062) Uploads: Added user-facing message for Laravel post limit handling - [`cc0827f`](https://github.com/BookStackApp/BookStack/commit/cc0827ff28988021e170e8abf0674ee5bb71b3da) Images: Updated to create thumbnails at specific events - [`5af3041`](https://github.com/BookStackApp/BookStack/commit/5af3041b9be351870cbe0c1eab82d7fa61fe0035) Thumbnails: Added OOM handling and regen endpoint - [`5c318a4`](https://github.com/BookStackApp/BookStack/commit/5c318a45b8afd11f6454f4a558a9616786c1a467) Images: Reverted some thumbnails to be on-demand generated - [`97274a8`](https://github.com/BookStackApp/BookStack/commit/97274a81401bc17ae3e79e77c7475f25a3193412) Images: Added test to cover thubmnail regen endpoint - [`4072143`](https://github.com/BookStackApp/BookStack/commit/40721433f721bf9233a57e5072493dba16c3552a) Image manager: Tweaked grid sizing to prevent massive items - [`7247e31`](https://github.com/BookStackApp/BookStack/commit/7247e31936ebf630b28be5870a5760be920b0d90) Images: Started refactor of image service - [`e703009`](https://github.com/BookStackApp/BookStack/commit/e703009d7fa6d1f3e448c23611ac907277412c42) Images: Added thin wrapper around image filesystem instances - [`20bcbd7`](https://github.com/BookStackApp/BookStack/commit/20bcbd76efdffa7537c7373197db4491ea846ab0) Images: Extracted out image resizing to its own class - [`b2d48d9`](https://github.com/BookStackApp/BookStack/commit/b2d48d9a7f52ae0d37567eec57469ea2d9c901d3) Images: Rolled out image memory handling to image actions ### 📊 Changes **29 files changed** (+854 additions, -525 deletions) <details> <summary>View changed files</summary> 📝 `app/Entities/Models/Book.php` (+4 -11) 📝 `app/Entities/Models/Bookshelf.php` (+7 -13) 📝 `app/Entities/Tools/ExportFormatter.php` (+1 -1) 📝 `app/Exceptions/Handler.php` (+41 -1) 📝 `app/Uploads/Controllers/DrawioImageController.php` (+18 -9) 📝 `app/Uploads/Controllers/GalleryImageController.php` (+21 -4) 📝 `app/Uploads/Controllers/ImageController.php` (+43 -14) 📝 `app/Uploads/Controllers/ImageGalleryApiController.php` (+5 -2) 📝 `app/Uploads/Image.php` (+4 -3) 📝 `app/Uploads/ImageRepo.php` (+10 -39) ➕ `app/Uploads/ImageResizer.php` (+206 -0) 📝 `app/Uploads/ImageService.php` (+39 -415) ➕ `app/Uploads/ImageStorage.php` (+136 -0) ➕ `app/Uploads/ImageStorageDisk.php` (+140 -0) 📝 `app/Users/Models/User.php` (+1 -1) ➕ `app/Util/OutOfMemoryHandler.php` (+58 -0) 📝 `lang/en/components.php` (+2 -0) 📝 `lang/en/errors.php` (+4 -0) 📝 `resources/js/components/image-manager.js` (+30 -5) 📝 `resources/js/markdown/actions.js` (+2 -2) _...and 9 more files_ </details> ### 📄 Description Related to #4454. - Adds friendlier handling, with proper message, for requests caught by Laravel's ValidatePostSize middleware. - Refactors and splits out much of the image file handling. ### Todo - [x] Roll out OOM handling to other endpoints where thumbs are created - [x] Roll out to gallery responses, so images are created via these means but the original view is still returned if an OOM occurance happens. Needs juggling of view and thumbnail gen. - [x] Drawings - [x] Images - [x] Test new thumbnail regen endpoint - [x] Fix large thumbnails when image manager only has single/few images in list. ### Notes - See `Illuminate\Foundation\Bootstrap\HandleExceptions` for example of reserving memory and handling errors (via `register_shutdown_function`). Can run custom hook through `register_shutdown_function`. Need to test conflicts with Laravel's own handling. - Need to consider for API also. ### Screenshots Preview of added image manager handling: ![Screenshot 2023-10-01 at 12-54-46 Editing Page Comment testing The BookStack](https://github.com/BookStackApp/BookStack/assets/8343178/0de8503a-eb58-45d8-8a1b-f09d20c0f110) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:30:45 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6379