[wp-trac] [WordPress Trac] #35390: image_constrain_size_for_editor() should not affect images generated on the front end when `large` size is used.
WordPress Trac
noreply at wordpress.org
Wed Mar 16 05:38:48 UTC 2016
#35390: image_constrain_size_for_editor() should not affect images generated on the
front end when `large` size is used.
----------------------------------------+------------------------
Reporter: rabmalin | Owner: joemcgill
Type: defect (bug) | Status: accepted
Priority: normal | Milestone: 4.5
Component: Media | Version: 4.4
Severity: normal | Resolution:
Keywords: needs-unit-tests has-patch | Focuses:
----------------------------------------+------------------------
Comment (by azaozz):
In my opinion `$context` in `image_constrain_size_for_editor()` was a bad
idea. It is very confusing: the function is called '''*_for_editor()''',
and the editor has one context: '''edit'''. Giving it another context
makes no sense.
Further #22738 made the media modal show wrong information:
https://core.trac.wordpress.org/attachment/ticket/22738/AttachmentDisplaySettings.png.
The actual size is 1024 X 768, the image inserted in the editor is 1024 X
768, but it is shown as 625 X 468 in the media modal?!?. The fact that we
display wrong, seemingly arbitrary values in there has caused a lot of
confusion to many users.
This is one of the most misused functions in WordPress. Over the years it
had several "hacks" to make it do stuff it wasn't intended to do. Setting
context based on `is_admin()` is very unreliable. An editor can easily be
on the front-end. Similarly, setting context just because it is an ajax
request is wrong and it makes it even more fragile and unreliable.
The right thing to do here is to deprecate
`image_constrain_size_for_editor()` and replace it with two or three new
functions that can handle all user cases properly.
Also agree with @joemcgill that we probably shouldn't change
`image_downsize()`. It shouldn't be using
`image_constrain_size_for_editor()` just to calculate the new image size
anyway. New function that does only that would have been perfect here (too
late now for 4.5).
If I have to pick, I'd rather add another param to `image_downsize()`
instead of tweaking `image_constrain_size_for_editor()` more.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35390#comment:17>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list