Make WordPress Core

Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#45203 closed defect (bug) (fixed)

Document all optional parameters as optional in add_image_size()

Reported by: drewapicture's profile DrewAPicture Owned by: andrewza's profile andrewza
Milestone: 5.1 Priority: normal
Severity: normal Version:
Component: Media Keywords: good-first-bug has-patch commit
Focuses: docs Cc:

Description (last modified by DrewAPicture)

The parameter descriptions for the optional $width and $height parameters for add_image_size() are not currently notated as such. Let's fix that.

For guidance on how to document optional parameters, note how the description for the optional fourth parameter, $crop, is formatted.

 * @param string     $name   Image size identifier.
 * @param int        $width  Image width in pixels.
 * @param int        $height Image height in pixels.
 * @param bool|array $crop   Optional. Whether to crop images to specified width and height or resize.
 *                           An array can specify positioning of the crop area. Default false.
function add_image_size( $name, $width = 0, $height = 0, $crop = false ) {

Attachments (2)

#45203.diff (809 bytes) - added by andrewza 5 years ago.
Patch #45203
#45203.1.diff (831 bytes) - added by andrewza 5 years ago.
Updated doc block further to include what the variables default to.

Download all attachments as: .zip

Change History (13)

#1 @DrewAPicture
5 years ago

  • Description modified (diff)

#2 @DrewAPicture
5 years ago

  • Milestone changed from Awaiting Review to Future Release

5 years ago

Patch #45203

#3 @andrewza
5 years ago

This my first WordPress core commit, hope this is right! Still getting the hang of it! #Contribute!

This patch adjusts the doc block.

5 years ago

Updated doc block further to include what the variables default to.

#4 @andrewza
5 years ago

  • Keywords has-patch added

#5 @swissspidy
5 years ago

  • Keywords commit added
  • Milestone changed from Future Release to 5.1
  • Owner set to andrewza
  • Status changed from new to assigned

Assigning the ticket to mark this good-first-bug as claimed.

Thanks for your contribution, @andrewza!

As per we currently focus on Gutenberg for 5.0, but by the looks of it we can commit this enhancement soon afterwards in the next release.

#6 @pento
5 years ago

In 43893:

Scripts: Fix a PHP error in admin-ajax calls.

When making an ajax request, wp_enqueue_registered_block_scripts_and_styles() checked if is_admin() was true before accessing $current_screen, rather than checking if $current_screen was defined. This is usually fine, execept for in ajax requests.

Props ocean90, foreverpinetree, pento.
See #45203.

#7 @pento
5 years ago

Ooops, wrong ticket number in that commit. 🙂

#8 @DrewAPicture
4 years ago

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

In 44329:

Docs: Ensure the optional $width and $height parameters are documented as such with defaults in the add_image_size() DocBlock.

Props andrewza.
Fixes #45203.

#9 @andrewza
4 years ago

Thanks @DrewAPicture, planning on doing more commits for 2019. Hopefully more advanced ones. Have a great day further!

#10 @DrewAPicture
4 years ago

Great! Look forward to it :-)

This ticket was mentioned in Slack in #meta by andrewlima. View the logs.

4 years ago

Note: See TracTickets for help on using tickets.