fix: decrease image size for Collections in certain cases#4395
Conversation
There was a problem hiding this comment.
Pull request overview
This PR optimizes image sizes used in Collections by introducing custom image sizes and applying smaller sizes for multi-column grid layouts. The change reduces bandwidth usage while maintaining acceptable image quality for grid displays with 4+ columns.
Changes:
- Introduced three custom image sizes (
newspack_collection_small,newspack_collection_medium,newspack_collection_large) to replace WordPress default sizes - Updated
get_image_size_from_attributes()to return smaller image sizes for grid layouts with 4+ columns (550px) and 3 columns (800px) - Updated corresponding unit tests to reflect the new image size mappings
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/blocks/collections/class-collections-block.php | Adds custom image size registration and updates logic to select appropriate sizes based on column count |
| tests/unit-tests/collections/class-test-collections-block.php | Updates test expectations to match new image size mappings and adds comprehensive coverage for different column scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@laurelfulford I've opened a new pull request, #4400, to work on those changes. Once the pull request is ready, I'll request review from you. |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
dkoo
left a comment
There was a problem hiding this comment.
This should work fine, but we already have some custom image sizes that are pretty close or identical to these. Would it be acceptable to use these instead, or at least for the medium/large sizes?
+-----------------------------------------------+-------+--------+------+-------+
| name | width | height | crop | ratio |
+-----------------------------------------------+-------+--------+------+-------+
| newspack-footer-logo | 400 | 9999 | soft | N/A |
| newspack-featured-image-small | 780 | 9999 | soft | N/A |
| newspack-featured-image | 1200 | 9999 | soft | N/A |
+-----------------------------------------------+-------+--------+------+-------+
|
Thanks @dkoo!
The only issue is that those image sizes live in the classic theme, they won't be available if you're using the block theme 😬 We could add a check and fallback to the classic theme ones if you're using that, if that wouldn't be too yucky? |
Gotcha, that makes sense. No need for the fancy fallbacks, then—better to keep things simple. We'll just want to make sure to regenerate media for sites who want the new sizes. |
dkoo
left a comment
There was a problem hiding this comment.
This is looking good, except the only scenario where I think the image ends up not being high-resolution enough is if you assign an image with a landscape-type aspect ratio to a collection and then show that collection in a single column. The CSS for collections enforces a 3/4 portrait-type aspect ratio, so the image is cropped on the sides and ends up being a little blurry. If you choose a portrait-style image, it's not a problem, and the aspect ratio + cropping didn't seem as noticeable to me at the smaller sizes.
|
Thanks @dkoo!
This is a good catch! I'm going to treat it as an "edge case" for now so we can keep the image sizes smaller, but will keep an eye out if it comes up from a publisher and either bump up an image size or maybe add an additional one. |
|
Hey @laurelfulford, good job getting this PR merged! 🎉 Now, the Please check if this PR needs to be included in the "Upcoming Changes" and "Release Notes" doc. If it doesn't, simply remove the label. If it does, please add an entry to our shared document, with screenshots and testing instructions if applicable, then remove the label. Thank you! ❤️ |
# [6.31.0-alpha.1](v6.30.1...v6.31.0-alpha.1) (2026-02-05) ### Bug Fixes * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.31.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.32.0-alpha.1](v6.31.0...v6.32.0-alpha.1) (2026-02-10) ### Bug Fixes * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.32.0-alpha.1 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
# [6.32.0](v6.31.1...v6.32.0) (2026-02-16) ### Bug Fixes * add check for my account before switching error notice ([#4484](#4484)) ([9e13eca](9e13eca)) * **collections:** hide indicator for unpublished collections ([#4434](#4434)) ([3eda622](3eda622)) * **content-gate:** persist restricted content ([#4420](#4420)) ([856695d](856695d)) * decrease image size for Collections in certain cases ([#4395](#4395)) ([de3c001](de3c001)) * **my-account:** "order again" checkout redirect ([#4427](#4427)) ([3a9e7fb](3a9e7fb)) * remove alignments from the My Account Block button ([#4438](#4438)) ([8de3526](8de3526)) ### Features * Add My Account button block ([#4409](#4409)) ([b0c414f](b0c414f)) * **avatar:** add custom byline support ([#4424](#4424)) ([152b1af](152b1af)) * **content-gate:** grouped access rules evaluation and normalization ([#4435](#4435)) ([aa182c9](aa182c9)) * **content-gate:** layout deletion and default content handling ([#4436](#4436)) ([f0b3b18](f0b3b18)) * **content-gate:** support group subscriptions access rule ([#4442](#4442)) ([416cd13](416cd13)) * **content-gate:** support new metering schema ([#4419](#4419)) ([e3f2f56](e3f2f56)) * **my-account:** new layout for single subscription pages ([#4425](#4425)) ([6425dbf](6425dbf)), closes [#4428](#4428) [#4432](#4432) [#4409](#4409) [#4419](#4419) [#4413](#4413) [#4434](#4434)
|
🎉 This PR is included in version 6.32.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
All Submissions:
Changes proposed in this Pull Request:
This PR adds some image sizes to the Collections code so we can reduce the image size that's used in some cases.
Originally, the code used
medium(defined in the Media Library, but defaulted to 300px),post-thumbnail(which is set to 1200px in our theme), and full size.This PR adds a small (550px), medium (800px), and large (1200px) image size, and tries to use them in a way that we're loading retina-sized images when we can, but also not loading anything beyond 1200px wide. This means a single collection taking up the full width of a one-column wide template will not be perfectly sharp on retina screens, but I think it's a sort of fine line we have to walk with not loading absolutely huge images.
See: NPPM-2520
How to test the changes in this Pull Request:
wp media regenerateor use the Regenerate Thumbnails plugin).Other information: