From f154a8f4d768fb7b276cac48ccfb697bf9d7c7a5 Mon Sep 17 00:00:00 2001 From: Mark Scherer Date: Fri, 21 Aug 2015 12:35:49 +0200 Subject: [PATCH] Fix MediaView extension handling as documented and expected. --- lib/Cake/View/MediaView.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/Cake/View/MediaView.php b/lib/Cake/View/MediaView.php index 77ba3c363..4cc4c131f 100644 --- a/lib/Cake/View/MediaView.php +++ b/lib/Cake/View/MediaView.php @@ -65,7 +65,7 @@ class MediaView extends View { * @return void */ public function render($view = null, $layout = null) { - $name = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; + $name = $extension = $download = $id = $modified = $path = $cache = $mimeType = $compress = null; extract($this->viewVars, EXTR_OVERWRITE); $path = $path . $id; @@ -86,7 +86,12 @@ class MediaView extends View { } if ($name !== null) { - $name .= '.' . pathinfo($id, PATHINFO_EXTENSION); + if (empty($extension)) { + $extension = pathinfo($id, PATHINFO_EXTENSION); + } + if (!empty($extension)) { + $name .= '.' . $extension; + } } $this->response->file($path, compact('name', 'download'));