Make WordPress Core


Ignore:
Timestamp:
05/30/2024 01:01:44 PM (10 months ago)
Author:
joedolson
Message:

Media: Protect mime type icon function from simple errors.

Handle $preferred_ext arguments that are passed with minor errors in formatting, such as incorrect casing or missing .. Add unit tests to verify that an omitted period on an otherwise correct extension is accepted. Follow up to [57687].

Props sabernhardt, joedolson, khokansardar.
Fixes #60610.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/post/attachments.php

    r54226 r58248  
    520520        $this->assertStringContainsString( 'images/media/video.png', $icon );
    521521    }
     522
     523    /**
     524     * @ticket 60610
     525     */
     526    public function test_wp_mime_type_icon_video_with_preferred_ext() {
     527        $icon1 = wp_mime_type_icon( 'video/mp4', '.png' ); // Added `$preferred_ext` parameter.
     528        $icon2 = wp_mime_type_icon( 'video/mp4', 'png' ); // Added `$preferred_ext` parameter without period.
     529
     530        $this->assertStringContainsString( 'images/media/video.png', $icon1, 'Mime type icon should be correctly returned with ".png" argument.' );
     531        $this->assertStringContainsString( 'images/media/video.png', $icon2, 'Mime type icon should be correctly returned with "png" argument.' );
     532    }
    522533}
Note: See TracChangeset for help on using the changeset viewer.