Add ability to look up page mime types from media.yaml - #966

This commit is contained in:
Andy Miller
2016-08-10 16:53:58 -06:00
parent 1c462e8784
commit b3f35fb16e
2 changed files with 14 additions and 0 deletions

View File

@@ -6,6 +6,7 @@
1. [](#improved)
* Improved `authorize` Twig extension to accept a nested array of authorizations [#948](https://github.com/getgrav/grav/issues/948)
* Don't add timestamps on remote assets as it can cause conflicts
* Grav now looks at types from `media.yaml` when retrieving page mime types [#966](https://github.com/getgrav/grav/issues/966)
1. [](#bugfix)
* Fixed `Folder::delete` method to recursively remove files and folders and causing Upgrade to fail.
* Fix [#952](https://github.com/getgrav/grav/issues/952) hypenize the session name.

View File

@@ -217,7 +217,10 @@ class Grav extends Container
*/
public function mime($format)
{
// look for some standard types
switch ($format) {
case null:
return 'text/html';
case 'json':
return 'application/json';
case 'html':
@@ -230,6 +233,16 @@ class Grav extends Container
return 'application/xml';
}
// Try finding mime type from media
$media_types = $this['config']->get('media.types');
if (key_exists($format, $media_types)) {
$type = $media_types[$format];
if (isset($type['mime'])) {
return $type['mime'];
}
}
// Can't find the mime type, send as HTML
return 'text/html';
}