WordPress.org

Make WordPress Core

Opened 3 weeks ago

Last modified 3 weeks ago

#50695 new enhancement

Make media_sideload_image extension list filterable

Reported by: paulschreiber Owned by:
Milestone: 5.6 Priority: normal
Severity: normal Version:
Component: Media Keywords: has-patch
Focuses: Cc:

Description

While upload_mimes is filterable and allows you to add additional items to the media library (i.e. SVGs), media_sideload_image() relies on an extension type check, and is not filterable.

Current behaviour:

<?php
preg_match( '/[^\?]+\.(jpe?g|jpe|gif|png)\b/i', $file, $matches );

Desired behaviour:

<?php
/**
 * Filters the file extensions used for media sideload.
 *
 * @since 5.5.0
 *
 * @param array $extensions The original extension list.
 */
$allowed_extensions =  apply_filters( 'media_sideload_extensions',  array( 'jpg', 'jpeg', 'jpe', 'png', 'gif' ) );
preg_match( '/[^\?]+\.(' . join( '|', allowed_extensions ) . ')\b/i', $file, $matches );

Change History (2)

This ticket was mentioned in PR #416 on WordPress/wordpress-develop by paulschreiber.


3 weeks ago

  • Keywords has-patch added

Makes media_sideload_image() extension list filterable.

Trac ticket: https://core.trac.wordpress.org/ticket/50695#ticket

#2 @SergeyBiryukov
3 weeks ago

  • Milestone changed from Awaiting Review to 5.6
Note: See TracTickets for help on using tickets.