Make WordPress Core

Ticket #48302: 48302.diff

File 48302.diff, 1.4 KB (added by kraftbj, 5 years ago)
  • src/wp-includes/media.php

    diff --git src/wp-includes/media.php src/wp-includes/media.php
    index 002581e174..ed2b9b285f 100644
    function _wp_add_additional_image_sizes() { 
    43864386        // 2x large size
    43874387        add_image_size( '2048x2048', 2048, 2048 );
    43884388}
     4389
     4390/**
     4391 * Retrieves the URL for an original image.
     4392 *
     4393 * WordPress Big Image processing will limit the scale of a large image by default. This function returns the absolute
     4394 * original image, not the scaled one.
     4395 *
     4396 * @since 5.3.0
     4397 *
     4398 * @param int $attachment_id Attachment ID.
     4399 * @return string|false Path to the original image file or false if the attachment is not an image.
     4400 */
     4401function wp_get_attachment_original_image_url( $attachment_id ) {
     4402        if ( ! wp_attachment_is_image( $attachment_id ) ) {
     4403                return false;
     4404        }
     4405
     4406        $image_meta = wp_get_attachment_metadata( $attachment_id );
     4407        $image_file = wp_get_attachment_image_url( $attachment_id, 'full' );
     4408
     4409        if ( empty( $image_meta['original_image'] ) ) {
     4410                $original_image = $image_file;
     4411        } else {
     4412                $original_image = path_join( dirname( $image_file ), $image_meta['original_image'] );
     4413        }
     4414
     4415        /**
     4416         * Filters the URL to the original image.
     4417         *
     4418         * @since 5.3.0
     4419         *
     4420         * @param string $original_image URL to original image file.
     4421         * @param int    $attachment_id  Attachment ID.
     4422         */
     4423        return apply_filters( 'wp_get_attachment_original_url', $original_image, $attachment_id );
     4424}