[wp-trac] [WordPress Trac] #39883: Code hooking on `image_downsize` can no longer assume the file is an image
WordPress Trac
noreply at wordpress.org
Wed Feb 15 19:58:16 UTC 2017
#39883: Code hooking on `image_downsize` can no longer assume the file is an image
--------------------------+------------------------------
Reporter: stephdau | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Media | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Description changed by stephdau:
Old description:
> In r38949, Core pretty drastically changed the expectations that any
> code hooking onto the `image_downsize` filter could make until now,
> potentially leading to issues for integrators.
>
> We went from having the `image_downsize()` function immediately return
> `false` if a file wasn't an image, not getting to that filter application
> at all, to only setting a variable with the result of the
> `wp_attachment_is_image( $id )` test and now applying the filter (not
> even passing said result, for that matter).
>
> This was a pretty big safe assumption to take away from under
> integrators' feet.
>
> Coupled to this, a wise integrator that might have picked up on this
> change could have wanted to have its own code have `image_downsize()`
> still returning `false` if it does not want to have the file further
> processed by the function, but there is no opportunity to, since
> returning `false` will cause `image_downsize()` to keep on with its
> processing instead of proceeding with `return $out`.
>
> Returning anything but false or null will cause `image_downsize()` to
> return, but that might not always be desirable to preserve the way WP
> worked prior to 4.7.
>
> What's better here for general use isn't as clear cut as what r38949 made
> it to be. I've discussed the case with @mikeschroder, and we've agreed to
> open this ticket so we can further discuss what should be done, if
> anything.
New description:
In r38949, Core pretty drastically changed the expectations that any code
hooking onto the `image_downsize` filter could make until then,
potentially leading to issues for integrators.
We went from having the `image_downsize()` function immediately return
`false` if a file wasn't an image, not getting to that filter application
at all, to only setting a variable with the result of the
`wp_attachment_is_image( $id )` test and now applying the filter (not even
passing said result, for that matter).
This was a pretty big safe assumption to take away from under integrators'
feet.
Coupled to this, a wise integrator that might have picked up on this
change could have wanted to have its own code have `image_downsize()`
still returning `false` if it does not want to have the file further
processed by the function, but there is no opportunity to, since returning
`false` will cause `image_downsize()` to keep on with its processing
instead of proceeding with `return $out`.
Returning anything but false or null will cause `image_downsize()` to
return, but that might not always be desirable to preserve the way WP
worked prior to 4.7.
What's better here for general use isn't as clear cut as what r38949 made
it to be. I've discussed the case with @mikeschroder, and we've agreed to
open this ticket so we can further discuss what should be done, if
anything.
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39883#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list