WordPress.org

Make WordPress Core

Changeset 49613


Ignore:
Timestamp:
11/16/2020 07:18:51 PM (11 months ago)
Author:
helen
Message:

Media: Avoid fatal error in `wp_prepare_attachment_for_js().

In certain contexts, in particular on the front-end, get_media_states() is not availble.

Props rebasaurus.
Fixes #51791.

File:
1 edited

Legend:

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

    r49597 r49613  
    40304030    }
    40314031
    4032     $media_states = get_media_states( $attachment );
    4033     if ( ! empty( $media_states ) ) {
    4034         $response['mediaStates'] = implode( ', ', $media_states );
     4032    if ( function_exists( 'get_media_states' ) ) {
     4033        $media_states = get_media_states( $attachment );
     4034        if ( ! empty( $media_states ) ) {
     4035            $response['mediaStates'] = implode( ', ', $media_states );
     4036        }
    40354037    }
    40364038
Note: See TracChangeset for help on using the changeset viewer.