mirror of
https://github.com/getgrav/grav.git
synced 2026-05-21 15:31:23 +02:00
Cherry-pick of #112
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user