mirror of
https://github.com/getgrav/grav.git
synced 2026-07-18 02:40:48 +02:00
Set template type based on request headers content-type if set
This commit is contained in:
@@ -1288,7 +1288,10 @@ class Page implements PageInterface
|
||||
}
|
||||
|
||||
if (empty($this->template_format)) {
|
||||
$this->template_format = Grav::instance()['uri']->extension('html');
|
||||
$content_type = Grav::instance()['uri']->getContentType(true);
|
||||
$fallback_type = Utils::getExtensionByMime($content_type);
|
||||
$default = is_null($content_type) ? Grav::instance()['uri']->extension('html') : $fallback_type;
|
||||
$this->template_format = $default;
|
||||
}
|
||||
|
||||
return $this->template_format;
|
||||
|
||||
@@ -1307,7 +1307,7 @@ class Uri
|
||||
* @param bool $short
|
||||
* @return null|string
|
||||
*/
|
||||
private function getContentType($short = true)
|
||||
public function getContentType($short = true)
|
||||
{
|
||||
if (isset($_SERVER['CONTENT_TYPE'])) {
|
||||
$content_type = $_SERVER['CONTENT_TYPE'];
|
||||
|
||||
Reference in New Issue
Block a user