WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#34257 closed defect (bug) (fixed)

Wrong order of width and height in image functions $size param descriptions

Reported by: jaspermdegroot Owned by: DrewAPicture
Milestone: 4.4 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: docs Cc:
PR Number:

Description

The image functions that accept an array with the image dimensions as argument for the $size parameter have a description of this parameter that says "a flat array of height and width values". This should be "width and height" since $size[0] has to be the width.

Affected functions in 'wp-includes/media.php':

  • image_constrain_size_for_editor (change "array of sizes" to "flat array of width and height values")
  • image_downsize
  • get_image_tag
  • image_get_intermediate_size
  • wp_get_attachment_image_src (also in the filter description)
  • wp_get_attachment_image
  • wp_get_attachment_image_url
  • gallery_shortcode: (@type $size description doesn't mention that it also accepts an array)
  • previous_image_link
  • next_image_link
  • adjacent_image_link

In 'wp-includes/post-template.php':

  • wp_get_attachment_link (change "@param string $size" to "@param string|array $size" and "either array or string" to "either string or flat array of width and height values")

The following functions in 'wp-includes/media.php' have a description of the $crop parameter with "specified height and width" in it. Although this isn't wrong, it might be better to change this to "width and height" as well to match the order of the parameters and for consistency.

  • add_image_size
  • set_post_thumbnail_size
  • image_resize_dimensions (also in the filter description)
  • image_make_intermediate_size

Change History (52)

#1 @swissspidy
4 years ago

  • Focuses docs added
  • Keywords needs-patch added
  • Type changed from defect (bug) to enhancement
  • Version trunk deleted

#2 @DrewAPicture
4 years ago

  • Owner set to DrewAPicture
  • Status changed from new to reviewing

#3 @DrewAPicture
4 years ago

  • Milestone changed from Awaiting Review to 4.4
  • Type changed from enhancement to defect (bug)

#4 @DrewAPicture
4 years ago

In 35033:

Docs: Adjust documentation for the $size parameter in image_constrain_size_for_editor() to clarify the required order of width and height values when passing an array.

See #34257.

#5 @DrewAPicture
4 years ago

In 35034:

Docs: Adjust documentation for the $size parameter in image_downsize() to clarify the required order of width and height values when passing an array.

See #34257.

#6 @DrewAPicture
4 years ago

In 35035:

Docs: Adjust documentation for the $size parameter in the image_downside hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#7 @DrewAPicture
4 years ago

In 35036:

Docs: Adjust documentation for the $size parameter in get_image_tag() to clarify the required order of width and height values when passing an array.

See #34257.

#8 @jaspermdegroot
4 years ago

@DrewAPicture

Thanks for fixing this!

Some of the responsive image functions that have been added for 4.4.0 also have a $size parameter that accepts an array of width and height values. This info is missing in the DocBlock. I am working on that with @joemcgill. See https://github.com/jaspermdegroot/develop.wordpress/commit/7c86df844e72b73f7cbf2057c1c8a38cef6ca1a3

#9 @DrewAPicture
4 years ago

  • Keywords has-patch added; needs-patch removed

In [35035], the referenced hook name should be image_downsize. Whoops.

#10 @DrewAPicture
4 years ago

In 35037:

Docs: Adjust documentation for the $size parameter in the get_image_tag_class hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#11 @DrewAPicture
4 years ago

In 35038:

Docs: Adjust documentation for the $size parameter in the get_image_tag hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#12 @DrewAPicture
4 years ago

In 35039:

Docs: Adjust documentation for the $size parameter in image_get_intermediate_size() to clarify the required order of width and height values when passing an array.

See #34257.

#13 @DrewAPicture
4 years ago

In 35040:

Docs: Adjust documentation for the $size parameter in wp_get_attachment_image_src() to clarify the required order of width and height values when passing an array.

See #34257.

#14 @DrewAPicture
4 years ago

In 35041:

Docs: Adjust documentation for the $size parameter in the wp_get_attachment_image_src hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#15 @DrewAPicture
4 years ago

In 35042:

Docs: Adjust documentation for the $size parameter in wp_get_attachment_image() to clarify the required order of width and height values when passing an array.

See #34257.

#16 @DrewAPicture
4 years ago

In 35043:

Docs: Adjust documentation for the $size parameter in the wp_get_attachment_image_attributes hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#17 @DrewAPicture
4 years ago

In 35044:

Docs: Adjust documentation for the $size parameter in wp_get_attachment_image_url() to clarify the required order of width and height values when passing an array.

See #34257.

#18 @DrewAPicture
4 years ago

In 35045:

Docs: Adjust documentation for the $size argument in gallery_shortcode to clarify the required order of width and height values when passing an array.

Also adds the array type to the argument documentation.

Props jaspermdegroot.
See #34257.

#19 @DrewAPicture
4 years ago

In 35046:

Docs: Normalize spacing in the $attr hash notation for gallery_shortcode() following [35045].

See #34257. See #32246.

#20 @DrewAPicture
4 years ago

In 35047:

Docs: Adjust documentation for the $size parameter in previous_image_link() to clarify the required order of width and height values when passing an array.

See #34257.

#21 @DrewAPicture
4 years ago

In 35048:

Docs: Adjust documentation for the $size parameter in next_image_link() to clarify the required order of width and height values when passing an array.

See #34257.

#22 @DrewAPicture
4 years ago

In 35049:

Docs: Adjust documentation for the $size parameter in adjacent_image_link() to clarify the required order of width and height values when passing an array.

See #34257.

#23 @DrewAPicture
4 years ago

In 35050:

Docs: Adjust documentation for the $size parameter in wp_get_attachment_link() to clarify the required order of width and height values when passing an array.

Also adds the array type to the parameter documentation (already supported).

Props jaspermdegroot.
See #34257.

#24 @DrewAPicture
4 years ago

In 35051:

Docs: Adjust the order of 'width' and 'height' (for consistency) for the $crop parameter documentation in add_image_size().

Props jaspermdegroot.
See #34257.

#25 @DrewAPicture
4 years ago

In 35052:

Docs: Adjust the order of 'width' and 'height' (for consistency) for the $crop parameter documentation in set_post_thumbnail_size().

Props jaspermdegroot.
See #34257.

#26 @DrewAPicture
4 years ago

In 35053:

Docs: Adjust the order of 'width' and 'height' (for consistency) for the $crop parameter documentation in image_resize_dimensions().

Also similarly adjusts the $crop parameter description in the corresponding image_resize_dimensions hook doc.

Props jaspermdegroot.
See #34257.

#27 @DrewAPicture
4 years ago

In 35054:

Docs: Adjust the order of 'width' and 'height' (for consistency) for the $crop parameter documentation in image_make_intermediate_size().

Props jaspermdegroot.
See #34257.

#28 @DrewAPicture
4 years ago

In 35055:

Docs: Adjust documentation for the $size parameter in get_image_send_to_editor() to clarify the required order of width and height values when passing an array.

Also adds the array type to the parameter documentation (already supported).

See #34257.

#29 @DrewAPicture
4 years ago

In 35056:

Docs: Fix syntax and properly mark optional parameters as such in the DocBlock for get_image_send_to_editor().

Also fixes the return description, and adds the $size default value, missed in [35055].

See #34257. See #32246.

#30 @DrewAPicture
4 years ago

In 35058:

Docs: Adjust documentation for the $size parameter in the image_send_to_editor hook doc to clarify the required order of width and height values when an array is passed.

Also adds the array type to the parameter documentation (already supported).

See #34257.

#31 @DrewAPicture
4 years ago

In 35059:

Docs: Normalize spacing in the image_send_to_editor hook doc following [35058].

See #34257. See #32246.

#32 @DrewAPicture
4 years ago

In 35060:

Docs: Adjust documentation for the $size parameter in the admin_post_thumbnail_size hook doc to clarify the required order of width and height values when an array is passed.

See #34257. See #28512.

#33 @DrewAPicture
4 years ago

In 35065:

Docs: Adjust documentation for the $size parameter in the wp_get_attachment_link hook doc to clarify the required order of width and height values when an array is passed.

Also adds the array type to the parameter documentation (already supported).

See #34257.

#34 @DrewAPicture
4 years ago

In 35066:

Docs: Normalize spacing in the wp_get_attachment_link hook doc following [35065].

See #34257. See #32246.

#35 @DrewAPicture
4 years ago

In 35067:

Docs: Adjust documentation for the $size parameter in the_post_thumbnail() to clarify the required order of width and height values when passing an array.

See #34257.

#36 @DrewAPicture
4 years ago

In 35068:

Docs: Adjust documentation for the $size parameter in get_the_post_thumbnail() to clarify the required order of width and height values when passing an array.

See #34257.

#37 @DrewAPicture
4 years ago

In 35069:

Docs: Adjust documentation for the $size parameter in the post_thumbnail_size hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#38 @DrewAPicture
4 years ago

In 35070:

Docs: Adjust documentation for the $size parameter in the begin_fetch_post_thumbnail_html hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#39 @DrewAPicture
4 years ago

In 35071:

Docs: Adjust documentation for the $size parameter in the end_fetch_post_thumbnail_html hook doc to clarify the required order of width and height values when an array is passed.

See #34257.

#40 @DrewAPicture
4 years ago

In 35072:

Docs: Adjust documentation for the $size parameter in the post_thumbnail_html hook doc to clarify the required order of width and height values when an array is passed.

Also adds the array type to the parameter documentation (already supported).

See #34257.

#41 @DrewAPicture
4 years ago

In 35073:

Docs: Normalize spacing in the post_thumbnail_html hook doc following [35072].

See #34257. See #32246.

#42 @DrewAPicture
4 years ago

In 35074:

Docs: The $size parameters in the begin_fetch_post_thumbnail_html and end_fetch_post_thumbnail_html hooks can also accept an array (already supported).

See #34257. See #32246. See [35070] and [35071].

#43 @DrewAPicture
4 years ago

In 35075:

Docs: The post_thumbnail_size hook can also accept an array (already supported).

See #34257. See [35069].

#44 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 35076:

Docs: Adjust documentation for the $size parameter in the_post_thumbnail_url() to clarify the required order of width and height values when passing an array.

Fixes #34257. Whew!

#45 @DrewAPicture
4 years ago

@jaspermdegroot That covers everything you listed and more that I found. Thanks for pointing that out! Let's do the responsive images-related docs adjustments in a new ticket.

#46 @DrewAPicture
4 years ago

  • Resolution fixed deleted
  • Status changed from closed to reopened

Missed adding array type to some of the earlier ones.

#47 @DrewAPicture
4 years ago

In 35077:

Docs: The $size parameter for the get_image_tag_class hook also accepts an array.

See #34257. See [35037].

#48 @DrewAPicture
4 years ago

In 35078:

Docs: The $size parameter for the get_image_tag hook also accepts an array.

See #34257. See [35038].

#49 @DrewAPicture
4 years ago

In 35079:

Docs: Normalize spacing in the DocBlock for get_image_send_to_editor() following [35056].

See #34257. See #32246.

#50 @DrewAPicture
4 years ago

In 35080:

Docs: Specify the default image size in the $size parameter description for the image_send_to_editor hook.

See #34257. See #32246. See [35058].

#51 @DrewAPicture
4 years ago

  • Resolution set to fixed
  • Status changed from reopened to closed

OK, now it's fixed. New tickets for related issues :-)

#52 @jaspermdegroot
4 years ago

@DrewAPicture Awesome! Yeah, we can open a separate ticket for responsive image docs if needed. Thanks!

Note: See TracTickets for help on using tickets.