WordPress.org

Make WordPress Core

Opened 21 months ago

Closed 19 months ago

Last modified 17 months ago

#45203 closed defect (bug) (fixed)

Document all optional parameters as optional in add_image_size()

Reported by: DrewAPicture Owned by: 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.

<?php
 *
 * @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 20 months ago.
Patch #45203
#45203.1.diff (831 bytes) - added by andrewza 20 months ago.
Updated doc block further to include what the variables default to.

Download all attachments as: .zip

Change History (13)

#1 @DrewAPicture
21 months ago

  • Description modified (diff)

#2 @DrewAPicture
21 months ago

  • Milestone changed from Awaiting Review to Future Release

@andrewza
20 months ago

Patch #45203

#3 @andrewza
20 months ago

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

This patch adjusts the doc block.

@andrewza
20 months ago

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

#4 @andrewza
20 months ago

  • Keywords has-patch added

#5 @swissspidy
20 months 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 https://make.wordpress.org/core/2018/10/05/wordpress-5-0-commit-management/ 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
20 months 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
20 months ago

Ooops, wrong ticket number in that commit. 🙂

#8 @DrewAPicture
19 months 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
19 months ago

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

#10 @DrewAPicture
19 months ago

Great! Look forward to it :-)

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


17 months ago

Note: See TracTickets for help on using tickets.