Cherry-pick of #112

This commit is contained in:
Djamil Legato
2015-01-16 14:44:25 -08:00
parent ce282c47cf
commit bdf80fd920
3 changed files with 43 additions and 0 deletions

View File

@@ -40,6 +40,31 @@ swf:
type: video
thumb: media/thumb-swf.png
mime: video/x-flv
flv:
type: video
thumb: media/thumb-flv.png
mime: video/x-flv
mp3:
type: audio
thumb: media/thumb-mp3.png
mime: audio/mp3
ogg:
type: audio
thumb: media/thumb-ogg.png
mine: audio/ogg
wma:
type: audio
thumb: media/thumb-wma.png
mine: audio/wma
m4a:
type: audio
thumb: media/thumb-m4a.png
mine: audio/m4a
wav:
type: audio
thumb: media/thumb-wav.png
mine: audio/wav
txt:
type: file

View File

@@ -23,6 +23,7 @@ class Media extends Getters
protected $instances = array();
protected $images = array();
protected $videos = array();
protected $audios = array();
protected $files = array();
/**
@@ -155,6 +156,17 @@ class Media extends Getters
return $this->videos;
}
/**
* Get a list of all audio media.
*
* @return array|Medium[]
*/
public function audios()
{
ksort($this->audios, SORT_NATURAL | SORT_FLAG_CASE);
return $this->audios;
}
/**
* Get a list of all file media.
*
@@ -179,6 +191,9 @@ class Media extends Getters
case 'video':
$this->videos[$file->filename] = $file;
break;
case 'audio':
$this->audios[$file->filename] = $file;
break;
default:
$this->files[$file->filename] = $file;
}

View File

@@ -450,6 +450,9 @@ class Page
if ($name == 'media.image') {
return $this->media()->images();
}
if ($name == 'media.audio') {
return $this->media()->audios();
}
$path = explode('.', $name);
$scope = array_shift($path);