Make WordPress Core

Ticket #27554: 27554.diff

File 27554.diff, 2.1 KB (added by wonderboymusic, 11 years ago)
  • src/wp-includes/js/media-audiovideo.js

     
    902902                }
    903903        });
    904904
    905         _.extend( wp.media.playlist, {
    906                 /**
    907                  * Determine how many audio and video files the user has uploaded
    908                  *
    909                  * @global wp.media.view.settings
    910                  *
    911                  * @param {Object} settings
    912                  * @returns {Object}
    913                  */
    914                 counts : (function(settings) {
    915                         var counts = {};
    916 
    917                         return  function() {
    918                                 if ( ! _.isEmpty( counts ) ) {
    919                                         return counts;
    920                                 }
    921 
    922                                 var a = 0, v = 0;
    923                                 _.each( settings.attachmentCounts, function(total, mime) {
    924                                         var type;
    925                                         if ( -1 < mime.indexOf('/') ) {
    926                                                 type = mime.split('/')[0];
    927 
    928                                                 total = parseInt(total, 10);
    929 
    930                                                 switch ( type ) {
    931                                                         case 'audio':
    932                                                                 a += total;
    933                                                         break;
    934                                                         case 'video':
    935                                                                 v += total;
    936                                                         break;
    937                                                 }
    938                                         }
    939                                 } );
    940 
    941                                 counts.audio = a;
    942                                 counts.video = v;
    943                                
    944                                 return counts;
    945                         };
    946                 }(media.view.settings))
    947         } );
    948 
    949905        /**
    950906         * Event binding
    951907         */
  • src/wp-includes/media.php

     
    23802380                }
    23812381        }
    23822382
     2383        $audio = $video = 0;
     2384        $counts = wp_count_attachments();
     2385        foreach ( $counts as $mime => $total ) {
     2386                if ( 0 === strpos( $mime, 'audio/' ) ) {
     2387                        $audio += (int) $total;
     2388                } elseif ( 0 === strpos( $mime, 'video/' ) ) {
     2389                        $video += (int) $total;
     2390                }
     2391        }
     2392
    23832393        $settings = array(
    23842394                'tabs'      => $tabs,
    23852395                'tabUrl'    => add_query_arg( array( 'chromeless' => true ), admin_url('media-upload.php') ),
     
    23922402                        'id' => 0,
    23932403                ),
    23942404                'defaultProps' => $props,
    2395                 'attachmentCounts' => wp_count_attachments(),
     2405                'attachmentCounts' => array(
     2406                        'audio' => $audio,
     2407                        'video' => $video
     2408                ),
    23962409                'embedExts'    => $exts,
    23972410                'embedMimes'   => $ext_mimes,
    23982411                'contentWidth' => $content_width,