diff --git a/app/views/oer/market/details.php b/app/views/oer/market/details.php index 7d54dc6cc9bcd1e9f86dfe6b2a3c07caaa0898c5..000e8a012dad9da474b1f673fd0d24a4bfd692e7 100644 --- a/app/views/oer/market/details.php +++ b/app/views/oer/market/details.php @@ -25,8 +25,10 @@ src="<?= htmlReady($url) ?>"></audio> </div> <? elseif ($material->isPDF()) : ?> - <iframe src="<?= htmlReady($url) ?>" - class="lernmarktplatz_player"></iframe> + <? if ($material->isPDFInlineDisplayable()) : ?> + <iframe src="<?= htmlReady($url) ?>" + class="lernmarktplatz_player"></iframe> + <? endif ?> <? elseif ($material['front_image_content_type']) : ?> <div style="background-image: url('<?= htmlReady($material->getLogoURL()) ?>');" class="lernmarktplatz_player image"></div> <? endif ?> diff --git a/lib/models/OERMaterial.php b/lib/models/OERMaterial.php index 7612f70f9853ad411cc6cb40333ea58016f8865e..dfd37d20ee99436ff7a73a49bb42055eca1f2131 100644 --- a/lib/models/OERMaterial.php +++ b/lib/models/OERMaterial.php @@ -322,6 +322,21 @@ class OERMaterial extends SimpleORMap return $this['content_type'] === "application/pdf"; } + public function isPDFInlineDisplayable() + { + if (!$this->isPDF()) { + return false; + } + $url = $this->getDownloadUrl(); + $headers = get_headers($url, true); + if ($headers['Content-Disposition'] + && substr($headers['Content-Disposition'], 0, strlen('attachment')) === 'attachment') { + //in this case the server forces to download the document and we cannot display it in an iframe: + return false; + } + return true; + } + protected function getFileEnding() { return pathinfo($this["filename"], PATHINFO_EXTENSION); diff --git a/resources/assets/stylesheets/scss/oer.scss b/resources/assets/stylesheets/scss/oer.scss index 0482f8ad937ab726723ea19bde326421aca8194c..f91ed7d70fcb9f1c93085791074baebb901cb52c 100644 --- a/resources/assets/stylesheets/scss/oer.scss +++ b/resources/assets/stylesheets/scss/oer.scss @@ -392,7 +392,8 @@ ul.reviews, ol.reviews { width: 840px; max-width: 100%; box-sizing: border-box; - min-height: 200px; + height: 200px; + max-height: 200px; overflow: hidden; .intro { display: flex;