Skip to content

fix: decrease image size for Collections in certain cases#4395

Merged
laurelfulford merged 6 commits into
trunkfrom
fix/decrease-collections-grid-size
Feb 4, 2026
Merged

fix: decrease image size for Collections in certain cases#4395
laurelfulford merged 6 commits into
trunkfrom
fix/decrease-collections-grid-size

Conversation

@laurelfulford
Copy link
Copy Markdown
Contributor

@laurelfulford laurelfulford commented Jan 13, 2026

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:

  1. Apply this PR.
  2. Regenerate the thumbnails (wp media regenerate or use the Regenerate Thumbnails plugin).
  3. View the /collections landing page and confirm that the main grid of images is using the new "small" size, 550px wide (it's kind of a random number, but it is double the size that these Collections can display at when they wrap to a three column grid for tablet-sized screens).
  4. Create a page and add 9 Collection blocks of different settings:
    • For the first six blocks, set them to use the grid layout and set them to one column, two columns, three columns... until you have a set that show the range from 1-6 columns.
    • For the final three blocks, set them to use the list layout and set the image sizes to small, medium, and large.
  5. Go through the images and open each in a new tab:
    • For the grid layout, the one and two column blocks should use a 1200px wide image; the 3 column block should use a 800px wide image, and the four to six column blocks should use a 550px wide image
    • For the list layout, the small image should be 550px, the medium image should be 800px, and the large image should be 1200px
  6. Do a general review of image quality using a retina screen. It will be most helpful if you use a graphic with text, like a true Collections cover from our of our publishers -- text and sharp edges will show image quality issues much readier than a regular photograph. It's expected that some will be a little softer than they were, but if any seem to be of a noticeable low quality, please flag here!

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

@laurelfulford laurelfulford requested a review from a team as a code owner January 13, 2026 20:36
@laurelfulford laurelfulford added the [Status] Needs Review The issue or pull request needs to be reviewed label Jan 13, 2026
@laurelfulford laurelfulford marked this pull request as draft January 13, 2026 21:44
@laurelfulford laurelfulford removed the [Status] Needs Review The issue or pull request needs to be reviewed label Jan 13, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/blocks/collections/class-collections-block.php Outdated
Comment thread src/blocks/collections/class-collections-block.php Outdated
Comment thread tests/unit-tests/collections/class-test-collections-block.php Outdated
Comment thread tests/unit-tests/collections/class-test-collections-block.php Outdated
Comment thread src/blocks/collections/class-collections-block.php Outdated
@laurelfulford laurelfulford marked this pull request as ready for review January 15, 2026 23:38
@laurelfulford laurelfulford requested a review from Copilot January 15, 2026 23:38
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/unit-tests/collections/class-test-collections-block.php Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/blocks/collections/class-collections-block.php
Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 15, 2026

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread tests/unit-tests/collections/class-test-collections-block.php
Copy link
Copy Markdown
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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   |
+-----------------------------------------------+-------+--------+------+-------+

@laurelfulford
Copy link
Copy Markdown
Contributor Author

Thanks @dkoo!

This should work fine, but we already have some custom image sizes that are pretty close or identical to these.

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?

@laurelfulford laurelfulford requested a review from dkoo February 3, 2026 20:23
@dkoo
Copy link
Copy Markdown
Contributor

dkoo commented Feb 3, 2026

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.

Copy link
Copy Markdown
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@github-actions github-actions Bot added the [Status] Approved The pull request has been reviewed and is ready to merge label Feb 3, 2026
@laurelfulford
Copy link
Copy Markdown
Contributor Author

Thanks @dkoo!

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.

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.

@laurelfulford laurelfulford merged commit de3c001 into trunk Feb 4, 2026
22 of 24 checks passed
@laurelfulford laurelfulford deleted the fix/decrease-collections-grid-size branch February 4, 2026 20:46
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 4, 2026

Hey @laurelfulford, good job getting this PR merged! 🎉

Now, the needs-changelog label has been added to it.

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! ❤️

matticbot pushed a commit that referenced this pull request Feb 5, 2026
# [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)
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 5, 2026

🎉 This PR is included in version 6.31.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Feb 10, 2026
# [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)
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.32.0-alpha.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

matticbot pushed a commit that referenced this pull request Feb 16, 2026
# [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)
@github-actions
Copy link
Copy Markdown

🎉 This PR is included in version 6.32.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Status] Approved The pull request has been reviewed and is ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants