Make WordPress Core


Ignore:
Timestamp:
02/02/2023 11:38:49 PM (2 years ago)
Author:
joedolson
Message:

Media: Add argument to get_attached_file() for subsizes.

Add a $size argument to get_attached_file() to simplify getting the path to an intermediate image size.

Props paulschreiber, audrasjb, Mista-Flo.
Fixes #51780.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/media/wpGenerateAttachmentMetadata.php

    r54863 r55199  
    1919     *
    2020     * @ticket 49412
     21     * @ticket 51780
    2122     *
    2223     * @covers ::wp_create_image_subsizes
     
    2930        $this->assertSame( wp_filesize( get_attached_file( $attachment ) ), $metadata['filesize'] );
    3031
    31         foreach ( $metadata['sizes'] as $intermediate_size ) {
     32        foreach ( $metadata['sizes'] as $size => $intermediate_size ) {
    3233            $this->assertArrayHasKey( 'filesize', $intermediate_size );
    3334            $this->assertNotEmpty( $intermediate_size['filesize'] );
    3435            $this->assertIsNumeric( $intermediate_size['filesize'] );
     36            $this->assertStringContainsString( $intermediate_size['file'], get_attached_file( $attachment, false, $size ) );
    3537        }
    3638    }
Note: See TracChangeset for help on using the changeset viewer.