diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 00f5ce4..a0ef1e7 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -115,10 +115,10 @@ public function initDisplay(ViewExecutable $view, array &$display, array &$optio if ($request_content_type != 'html') { $this->setContentType($request_content_type); } - // If the requested content-type is 'html' and we only have 1 format option - // selected in the view display options, set that as the default content - // type. - elseif (isset($options['style']['options']['formats']) && count($options['style']['options']['formats']) == 1) { + // If the requested content type is 'html' and the default 'json' is not + // selected as a format option in the view display, fallback to the first + // format in the array. + elseif (!empty($options['style']['options']['formats']) && !isset($options['style']['options']['formats'][$this->getContentType()])) { $this->setContentType(reset($options['style']['options']['formats'])); }