feat: add document options `is_image`

This commit is contained in:
vnmedeiros 2021-10-15 10:43:31 -03:00
parent 732464e123
commit 22a14b956a
2 changed files with 8 additions and 3 deletions

View File

@ -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('<a href="%s" target="blank"><img src="%s" /></a>', $url, $url);
// URL points to a content that is not an image

View File

@ -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',