From bdf80fd9205a71a8f1decf0eb6f44a2ccc847929 Mon Sep 17 00:00:00 2001 From: Djamil Legato Date: Fri, 16 Jan 2015 14:44:25 -0800 Subject: [PATCH] Cherry-pick of #112 --- system/config/media.yaml | 25 +++++++++++++++++++++++++ system/src/Grav/Common/Page/Media.php | 15 +++++++++++++++ system/src/Grav/Common/Page/Page.php | 3 +++ 3 files changed, 43 insertions(+) diff --git a/system/config/media.yaml b/system/config/media.yaml index 40385268e..f5a4795da 100644 --- a/system/config/media.yaml +++ b/system/config/media.yaml @@ -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 diff --git a/system/src/Grav/Common/Page/Media.php b/system/src/Grav/Common/Page/Media.php index ca175c7b4..97ac69962 100644 --- a/system/src/Grav/Common/Page/Media.php +++ b/system/src/Grav/Common/Page/Media.php @@ -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; } diff --git a/system/src/Grav/Common/Page/Page.php b/system/src/Grav/Common/Page/Page.php index f493a3540..f7e1cd212 100644 --- a/system/src/Grav/Common/Page/Page.php +++ b/system/src/Grav/Common/Page/Page.php @@ -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);