Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic downsizing of larger-than-necessary images #32

Merged
merged 10 commits into from
Jul 29, 2024

Conversation

ababic
Copy link
Collaborator

@ababic ababic commented Jul 3, 2024

NOTE: Includes changes from #31, which should be reviewed/merged first

Contrary to what you might think from reviewing the documentation on the subject, setting up custom derivatives that appear in API responses alongside the default mini, thul and webimage values is quite limited, and my client couldn't find a way to reliably restrict the dimensions for WagtailSource as we had agreed.

Since Wagtail has everything we need to manipulate images on-the-fly, I thought a sensible way to avoid unreasonably large images from making it into a library (a leading cause of memory usage issues on Wagtail sites) would be to introduce the BYNDER_SOURCE_IMAGE_MAX_WIDTH and BYNDER_SOURCE_IMAGE_MAX_HEIGHT settings, and use them to check and downsize downloaded images before using them to set the source file.

@ababic ababic force-pushed the feature/resize-downloaded-images branch 2 times, most recently from 618b814 to ce0701d Compare July 3, 2024 13:03
src/wagtail_bynder/utils.py Outdated Show resolved Hide resolved
@ababic ababic force-pushed the feature/resize-downloaded-images branch 12 times, most recently from 4ed67fb to bf90110 Compare July 4, 2024 19:50
@ababic ababic requested a review from zerolab July 4, 2024 20:07
@ababic ababic marked this pull request as draft July 5, 2024 08:50
@ababic ababic force-pushed the feature/resize-downloaded-images branch 4 times, most recently from c0a2448 to 0e04177 Compare July 5, 2024 12:21
@ababic ababic marked this pull request as ready for review July 5, 2024 12:21
@ababic ababic force-pushed the feature/resize-downloaded-images branch from 0e04177 to c1fcee7 Compare July 10, 2024 14:48
@ababic ababic force-pushed the feature/resize-downloaded-images branch 4 times, most recently from 56db87d to f737355 Compare July 29, 2024 15:55
@ababic ababic force-pushed the feature/resize-downloaded-images branch from f737355 to 43007aa Compare July 29, 2024 16:02
@ababic ababic force-pushed the feature/resize-downloaded-images branch from c5907bd to b1d2bd6 Compare July 29, 2024 16:22
@ababic ababic merged commit 13343d5 into main Jul 29, 2024
6 checks passed
@ababic ababic deleted the feature/resize-downloaded-images branch July 29, 2024 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant