mirror of
https://github.com/getgrav/grav.git
synced 2026-05-07 15:55:53 +02:00
Add ability to look up page mime types from media.yaml - #966
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user