Make WordPress Core


Ignore:
Timestamp:
09/30/2019 04:27:11 PM (7 years ago)
Author:
azaozz
Message:

Media: Move wp_get_original_image_path() to wp-content/post.php to make it easier to access from plugins.

Props pbiron.
See #47873.

File:
1 edited

Legend:

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

    r46217 r46353  
    10351035        return $dst_file;
    10361036}
    1037 
    1038 /**
    1039  * Retrieves the path to an uploaded image.
    1040  *
    1041  * Similar to `get_attached_file()` however some images may have been
    1042  * processed after uploading to make them "web ready".
    1043  * In this case this function returns the path to the originally uploaded image file.
    1044  *
    1045  * @since 5.3.0
    1046  *
    1047  * @param int $attachment_id Attachment ID.
    1048  * @return string|false Path to the original image file or false if the attachment is not an image.
    1049  */
    1050 function wp_get_original_image_path( $attachment_id ) {
    1051         if ( ! wp_attachment_is_image( $attachment_id ) ) {
    1052                 return false;
    1053         }
    1054 
    1055         $image_meta = wp_get_attachment_metadata( $attachment_id );
    1056         $image_file = get_attached_file( $attachment_id );
    1057 
    1058         if ( empty( $image_meta['original_image'] ) ) {
    1059                 $original_image = $image_file;
    1060         } else {
    1061                 $original_image = path_join( dirname( $image_file ), $image_meta['original_image'] );
    1062         }
    1063 
    1064         /**
    1065          * Filters the path to the original image.
    1066          *
    1067          * @since 5.3.0
    1068          *
    1069          * @param string $original_image Path to original image file.
    1070          * @param int    $attachment_id  Attachment ID.
    1071          */
    1072         return apply_filters( 'wp_get_original_image_path', $original_image, $attachment_id );
    1073 }
Note: See TracChangeset for help on using the changeset viewer.