[wp-trac] [WordPress Trac] #12120: Force Media Image Generation (for thumbnails)
WordPress Trac
noreply at wordpress.org
Sat Jan 10 22:22:05 UTC 2015
#12120: Force Media Image Generation (for thumbnails)
-------------------------------------+------------------
Reporter: atow | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 4.2
Component: Media | Version:
Severity: normal | Resolution:
Keywords: has-patch needs-testing | Focuses:
-------------------------------------+------------------
Comment (by ericlewis):
The fact that a thumb size in cases like @atow described in the original
report is a bummer. Instead of not generating image sizes bigger than the
original, we should scale up so that these cuts are generated. Whether
they are pixelated shouldn't be WordPress' business, which I'm guessing
was the idea behind not creating the bigger cuts.
`image_make_intermediate_size()` is the public function for resizing an
image. Although there are also public methods on the WP_Image_Editor_*
instance, `image_make_intermediate_size()` is a façade layer for this.
`image_resize_dimensions()` seems to be the place where logic to do
regarding resizing, as it generates the parameters for
`imagecopyresampled()`, so I've modified some of this logic.
attachment:12120.diff is a go at this.
`image_resize_dimensions()` has been modified to default to upscaling
images.
I've also created a new function, `wp_scale_dimensions()`, which is
`wp_constrain_dimensions()` but with an option for upscaling.
`wp_constrain_dimensions()` now calls `wp_scale_dimensions()` with a
disallow upscaling flag for backwards compatibility. We could've jammed
this logic into `wp_constrain_dimensions()`, but it seems apt to make a
separate, more self-describing function with the extra option.
I added a unit test and modified old ones which expected images not to be
scaled up.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/12120#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list