Media: Improve display and accessibility of meta data in detail view.

* Add a `human_readable_duration` function including tests.
* Add 'pixels' after image width/height.
* Add screen reader text for durations.

Props Presskopp, kiranpotphode, milindmore22, stormrockwell, afercia.
Fixes #39667. 



git-svn-id: https://develop.svn.wordpress.org/trunk@43633 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Adam Silverstein
2018-09-08 04:19:40 +00:00
parent 37b53387ff
commit fd5ba80c5c
4 changed files with 119 additions and 7 deletions

View File

@@ -1518,4 +1518,43 @@ class Tests_Functions extends WP_UnitTestCase {
array( '/leading/relative/path', false ),
);
}
/**
* Test the human_readable_duration function.
*
* @ticket 39667
* @dataProvider _datahuman_readable_duration()
*
* @param $input
* @param $expected
*/
public function test_duration_format( $input, $expected ) {
$this->assertSame( $expected, human_readable_duration( $input ) );
}
public function _datahuman_readable_duration() {
return array(
array( array(), false ),
array( '30:00', '30 minutes, 0 seconds' ),
array( 'Batman Begins !', false ),
array( '', false ),
array( '-1', false ),
array( -1, false ),
array( 0, false ),
array( 1, false ),
array( '00', false ),
array( '00:00', '0 minutes, 0 seconds' ),
array( '00:00:00', '0 hours, 0 minutes, 0 seconds' ),
array( '10:30:34', '10 hours, 30 minutes, 34 seconds' ),
array( '00:30:34', '0 hours, 30 minutes, 34 seconds' ),
array( 'MM:30:00', false ),
array( '30:MM', false ),
array( 'MM:00', false ),
array( 'MM:MM', false ),
array( '01:01', '1 minute, 1 second' ),
array( '01:01:01', '1 hour, 1 minute, 1 second' ),
array( '0:05', '5 seconds' ),
array( '1:02:00', '1 hour, 2 minutes, 0 seconds' ),
);
}
}