Add filter for default max image width #6467
                
     Draft
            
            
          
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    


Description
This pull request introduces a filter to make the default maximum width for image resizing configurable in the
image_resizemethod, which originally filter's WordPress core'simage_downsizefilter. This allows users to override the default value of 1024 pixels via thevip_go_default_image_max_widthfilter.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 sizefull— instead of theheader-bg-1920size. The various helper functions (e.g.,wp_get_attachment_image_src,wp_get_attachment_image, etc) will use the set1024value for various HTML output attributues.Programmatically, you could pass
header-bg-1920in your calling functions, but if there is code in a 3rd party plugin that generates size options via attachment meta, theheader-bg-1920size won't be available to select, as WordPress core excludes it because of wp_image_resize_identical_dimensions.The
image_resizefilter does take into account the "content_width" if defined, but setting a customcontent_widthshouldn't be a solution here, as "full width" header images wouldn't be analogous to the desired main content width.Changelog Description
Added
Pre-review checklist
Please make sure the items below have been covered before requesting a review:
Pre-deploy checklist
Steps to Test