get_post_mime_types example


    $infinite_scrolling = apply_filters( 'media_library_infinite_scrolling', false );

    $settings = array(
        'tabs'              => $tabs,
        'tabUrl'            => add_query_arg( array( 'chromeless' => true )admin_url( 'media-upload.php' ) ),
        'mimeTypes'         => wp_list_pluck( get_post_mime_types(), 0 ),
        /** This filter is documented in wp-admin/includes/media.php */
        'captions'          => ! apply_filters( 'disable_captions', '' ),
        'nonce'             => array(
            'sendToEditor'           => wp_create_nonce( 'media-send-to-editor' ),
            'setAttachmentThumbnail' => wp_create_nonce( 'set-attachment-thumbnail' ),
        ),
        'post'              => array(
            'id' => 0,
        ),
        'defaultProps'      => $props,
        'attachmentCounts'  => array(
            

    $parsed_args = apply_filters( 'get_media_item_args', $parsed_args );

    $toggle_on  = __( 'Show' );
    $toggle_off = __( 'Hide' );

    $file     = get_attached_file( $post->ID );
    $filename = esc_html( wp_basename( $file ) );
    $title    = esc_attr( $post->post_title );

    $post_mime_types = get_post_mime_types();
    $keys            = array_keys( wp_match_mime_types( array_keys( $post_mime_types )$post->post_mime_type ) );
    $type            = reset( $keys );
    $type_html       = "<input type='hidden' id='type-of-$attachment_id' value='" . esc_attr( $type ) . "' />";

    $form_fields = get_attachment_fields_to_edit( $post$parsed_args['errors'] );

    if ( $parsed_args['toggle'] ) {
        $class        = empty( $parsed_args['errors'] ) ? 'startclosed' : 'startopen';
        $toggle_links = " <a class='toggle describe-toggle-on' href='#'>$toggle_on</a> <a class='toggle describe-toggle-off' href='#'>$toggle_off</a>";
    }


    /** * Filters the number of items to list per page when listing media items. * * @since 2.9.0 * * @param int $media_per_page Number of media to list. Default 20. */
    $q['posts_per_page'] = apply_filters( 'upload_per_page', $media_per_page );

    $post_mime_types = get_post_mime_types();
    if ( isset( $q['post_mime_type'] ) && ! array_intersect( (array) $q['post_mime_type']array_keys( $post_mime_types ) ) ) {
        unset( $q['post_mime_type'] );
    }

    foreach ( array_keys( $post_mime_types ) as $type ) {
        if ( isset( $q['attachment-filter'] ) && "post_mime_type:$type" === $q['attachment-filter'] ) {
            $q['post_mime_type'] = $type;
            break;
        }
    }

    
Home | Imprint | This part of the site doesn't use cookies.