From 22a14b956abc9c7a89a91ae69d97b538f174a2ad Mon Sep 17 00:00:00 2001 From: vnmedeiros Date: Fri, 15 Oct 2021 10:43:31 -0300 Subject: [PATCH] feat: add document options `is_image` --- src/classes/entities/class-tainacan-item.php | 4 +--- src/classes/repositories/class-tainacan-items.php | 7 +++++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/classes/entities/class-tainacan-item.php b/src/classes/entities/class-tainacan-item.php index ddc7eb7c3..b23fcdfad 100644 --- a/src/classes/entities/class-tainacan-item.php +++ b/src/classes/entities/class-tainacan-item.php @@ -719,10 +719,8 @@ class Item extends Entity { if ( $document_options && isset($document_options['forced_iframe']) && $document_options['forced_iframe'] === true ) { - $headers = get_headers($url, 1); - // URL points to an image file - if (strpos($headers['Content-Type'], 'image/') !== false) { + if (isset($document_options['is_image']) && $document_options['is_image'] === true) { $_embed = sprintf('', $url, $url); // URL points to a content that is not an image diff --git a/src/classes/repositories/class-tainacan-items.php b/src/classes/repositories/class-tainacan-items.php index 62af146d3..97de52af4 100644 --- a/src/classes/repositories/class-tainacan-items.php +++ b/src/classes/repositories/class-tainacan-items.php @@ -117,6 +117,13 @@ class Items extends Repository { 'context' => array( 'view', 'edit', 'embed' ), 'default' => false ), + 'is_image' => array( + 'title' => __( 'Is link to external image', 'tainacan' ), + 'description' => __( 'Is link to external image', 'tainacan' ), + 'type' => 'boolean', + 'context' => array( 'view', 'edit', 'embed' ), + 'default' => false + ), 'forced_iframe_height' => array( 'description' => __( 'Iframe height (px)', 'tainacan' ), 'type' => 'number',