[wp-trac] [WordPress Trac] #34225: Add context to image_constrain_size_for_editor for media modal dropdown, to show proper image size dimensions

WordPress Trac noreply at wordpress.org
Thu Oct 8 22:08:38 UTC 2015


#34225: Add context to image_constrain_size_for_editor for media modal dropdown, to
show proper image size dimensions
----------------------------+-----------------------------
 Reporter:  krogsgard       |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Media           |    Version:  4.3.1
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 In the media modal dropdown, the available image sizes and their
 dimensions are shown like this:

 [[Image(https://cldup.com/fO5zZgC7OV.png)]]

 But the image dimensions are actually larger. The shown values are
 restricted because of the theme's `$content_width` variable. The actual
 values are like this:

 [[Image(https://cldup.com/DHFDDrEnlb.png)]]

 This dropdown is for informational purposes only, and the actual image
 size should show, not the constrained dimensions that will be in the media
 markup (largely for TinyMCE / editor purposes I believe).

 These image sizes are output to this modal template from `wp-includes
 /media-template.php`, and that data is setup from
 `wp_prepare_attachment_for_js`.

 This function calls the `image_constrain_size_for_editor`, which has a
 fourth parameter for `context`. That parameter is set to be `edit` both
 here and by default, and therefore the image constraints are set to this
 dropdown, even though it is for informational purposes only.

 Current contexts documented currently are `edit` or `display`. `edit` is
 the default if `is_admin()` returns true. There should be a third context,
 that does no constrain the image size, if the purpose for grabbing the
 image size is for informational purposes. Therefore, I think the best
 solution is to allow for a new `context` that I'm calling `info`.

 The new context would override the `admin` context, but not override the
 width parameter on the inserted media (that's useful for editor/TinyMCE
 purposes), nor would it override anything on the front end. It just edits
 it for reference purposes in the dropdown, to prevent innaccurate
 information from being presented to the user.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/34225>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list