Make WordPress Core


Ignore:
Timestamp:
01/18/2020 12:52:28 AM (6 years ago)
Author:
SergeyBiryukov
Message:

Docs: Improve comments in some wp-admin files per the documentation standards.

Props passoniate.
Fixes #49215, #49216.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/image.php

    r46809 r47084  
    2525function wp_crop_image( $src, $src_x, $src_y, $src_w, $src_h, $dst_w, $dst_h, $src_abs = false, $dst_file = false ) {
    2626    $src_file = $src;
    27     if ( is_numeric( $src ) ) { // Handle int as attachment ID
     27    if ( is_numeric( $src ) ) { // Handle int as attachment ID.
    2828        $src_file = get_attached_file( $src );
    2929
     
    118118    }
    119119
    120     // Remove sizes that already exist. Only checks for matching "size names".
    121     // It is possible that the dimensions for a particular size name have changed.
    122     // For example the user has changed the values on the Settings -> Media screen.
    123     // However we keep the old sub-sizes with the previous dimensions
    124     // as the image may have been used in an older post.
     120    /*
     121     * Remove sizes that already exist. Only checks for matching "size names".
     122     * It is possible that the dimensions for a particular size name have changed.
     123     * For example the user has changed the values on the Settings -> Media screen.
     124     * However we keep the old sub-sizes with the previous dimensions
     125     * as the image may have been used in an older post.
     126     */
    125127    $missing_sizes = array_diff_key( $possible_sizes, $image_meta['sizes'] );
    126128
     
    230232    }
    231233
    232     // Default image meta
     234    // Default image meta.
    233235    $image_meta = array(
    234236        'width'  => $imagesize[0],
     
    319321            }
    320322
    321             // Rotate the image
     323            // Rotate the image.
    322324            $rotated = $editor->maybe_exif_rotate();
    323325
     
    340342    }
    341343
    342     // Initial save of the new metadata.
    343     // At this point the file was uploaded and moved to the uploads directory
    344     // but the image sub-sizes haven't been created yet and the `sizes` array is empty.
     344    /*
     345     * Initial save of the new metadata.
     346     * At this point the file was uploaded and moved to the uploads directory
     347     * but the image sub-sizes haven't been created yet and the `sizes` array is empty.
     348     */
    345349    wp_update_attachment_metadata( $attachment_id, $image_meta );
    346350
     
    387391    if ( isset( $image_meta['sizes'] ) && is_array( $image_meta['sizes'] ) ) {
    388392        foreach ( $image_meta['sizes'] as $size_name => $size_meta ) {
    389             // Only checks "size name" so we don't override existing images even if the dimensions
    390             // don't match the currently defined size with the same name.
    391             // To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
     393            /*
     394             * Only checks "size name" so we don't override existing images even if the dimensions
     395             * don't match the currently defined size with the same name.
     396             * To change the behavior, unset changed/mismatched sizes in the `sizes` array in image meta.
     397             */
    392398            if ( array_key_exists( $size_name, $new_sizes ) ) {
    393399                unset( $new_sizes[ $size_name ] );
     
    403409    }
    404410
    405     // Sort the image sub-sizes in order of priority when creating them.
    406     // This ensures there is an appropriate sub-size the user can access immediately
    407     // even when there was an error and not all sub-sizes were created.
     411    /*
     412     * Sort the image sub-sizes in order of priority when creating them.
     413     * This ensures there is an appropriate sub-size the user can access immediately
     414     * even when there was an error and not all sub-sizes were created.
     415     */
    408416    $priority = array(
    409417        'medium'       => null,
     
    734742            }
    735743
    736             if ( ! empty( $iptc['2#110'][0] ) ) { // credit
     744            if ( ! empty( $iptc['2#110'][0] ) ) { // Credit.
    737745                $meta['credit'] = trim( $iptc['2#110'][0] );
    738             } elseif ( ! empty( $iptc['2#080'][0] ) ) { // creator / legacy byline
     746            } elseif ( ! empty( $iptc['2#080'][0] ) ) { // Creator / legacy byline.
    739747                $meta['credit'] = trim( $iptc['2#080'][0] );
    740748            }
    741749
    742             if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // created date and time
     750            if ( ! empty( $iptc['2#055'][0] ) && ! empty( $iptc['2#060'][0] ) ) { // Created date and time.
    743751                $meta['created_timestamp'] = strtotime( $iptc['2#055'][0] . ' ' . $iptc['2#060'][0] );
    744752            }
    745753
    746             if ( ! empty( $iptc['2#116'][0] ) ) { // copyright
     754            if ( ! empty( $iptc['2#116'][0] ) ) { // Copyright.
    747755                $meta['copyright'] = trim( $iptc['2#116'][0] );
    748756            }
    749757
    750             if ( ! empty( $iptc['2#025'][0] ) ) { // keywords array
     758            if ( ! empty( $iptc['2#025'][0] ) ) { // Keywords array.
    751759                $meta['keywords'] = array_values( $iptc['2#025'] );
    752760            }
     
    774782
    775783            if ( empty( $meta['title'] ) && $description_length < 80 ) {
    776                 // Assume the title is stored in ImageDescription
     784                // Assume the title is stored in ImageDescription.
    777785                $meta['title'] = trim( $exif['ImageDescription'] );
    778786            }
Note: See TracChangeset for help on using the changeset viewer.