Skip to content

Conversation

@seanlanglands
Copy link
Contributor

Description

This pull request introduces a filter to make the default maximum width for image resizing configurable in the image_resize method, which originally filter's WordPress core's image_downsize filter. This allows users to override the default value of 1024 pixels via the vip_go_default_image_max_width filter.

Here's a niche use case where one would want to change this default value:

WordPress intentionally omits generating a transformed image if the image's full size is the same as a custom image size. Separate transformed images are not generated on the VIP File System, but this WordPress core behavior does affect how registered custom image sizes are made available.

Say we create a new image size (e.g., add_image_size( 'header-bg-1920', 1920, 1920)), upload an image with the exact width (1920), and then choose to use size full — instead of the header-bg-1920 size. The various helper functions (e.g., wp_get_attachment_image_src, wp_get_attachment_image, etc) will use the set 1024 value for various HTML output attributues.

Programmatically, you could pass header-bg-1920 in your calling functions, but if there is code in a 3rd party plugin that generates size options via attachment meta, the header-bg-1920 size won't be available to select, as WordPress core excludes it because of wp_image_resize_identical_dimensions.

The image_resize filter does take into account the "content_width" if defined, but setting a custom content_width shouldn't be a solution here, as "full width" header images wouldn't be analogous to the desired main content width.

Changelog Description

Added

  • Added filter to make the default maximum width for image resizing configurable.

Pre-review checklist

Please make sure the items below have been covered before requesting a review:

  • This change works and has been tested locally or in Codespaces (or has an appropriate fallback).
  • This change works and has been tested on a sandbox.
  • This change has relevant unit tests (if applicable).
  • This change uses a rollout method to ease with deployment (if applicable - especially for large scale actions that require writes).
  • This change has relevant documentation additions / updates (if applicable).
  • I've created a changelog description that aligns with the provided examples.

Pre-deploy checklist

  • VIP staff: Ensure any alerts added/updated conform to internal standards (see internal documentation).

Steps to Test

@codecov
Copy link

codecov bot commented Aug 18, 2025

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 33.36%. Comparing base (69edeb8) to head (1f6c46c).
⚠️ Report is 48 commits behind head on develop.

Files with missing lines Patch % Lines
a8c-files.php 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #6467   +/-   ##
==========================================
  Coverage      33.36%   33.36%           
  Complexity      4938     4938           
==========================================
  Files            291      291           
  Lines          20953    20953           
==========================================
  Hits            6990     6990           
  Misses         13963    13963           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud
Copy link

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.

3 participants