diff --git a/bridges/CssSelectorBridge.php b/bridges/CssSelectorBridge.php index 8fba5285..5b2625a9 100644 --- a/bridges/CssSelectorBridge.php +++ b/bridges/CssSelectorBridge.php @@ -56,6 +56,11 @@ class CssSelectorBridge extends BridgeAbstract 'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.', 'type' => 'checkbox', ], + 'thumbnail_as_header' => [ + 'name' => '[Optional] Insert thumbnail as article header', + 'title' => 'Insert article main image on top of article contents.', + 'type' => 'checkbox', + ], 'limit' => self::LIMIT ] ]; @@ -89,6 +94,7 @@ class CssSelectorBridge extends BridgeAbstract $content_cleanup = $this->getInput('content_cleanup'); $title_cleanup = $this->getInput('title_cleanup'); $discard_thumbnail = $this->getInput('discard_thumbnail'); + $thumbnail_as_header = $this->getInput('thumbnail_as_header'); $limit = $this->getInput('limit') ?? 10; $html = defaultLinkTo(getSimpleHTMLDOM($this->homepageUrl), $this->homepageUrl); @@ -109,6 +115,9 @@ class CssSelectorBridge extends BridgeAbstract if ($discard_thumbnail && isset($item['enclosures'])) { unset($item['enclosures']); } + if ($thumbnail_as_header && isset($item['enclosures'][0])) { + $item['content'] = '

' . $item['content']; + } $this->items[] = $item; } } @@ -311,6 +320,7 @@ class CssSelectorBridge extends BridgeAbstract // Facebook Open Graph (og:KEY) - https://developers.facebook.com/docs/sharing/webmasters // Twitter (twitter:KEY) - https://developer.twitter.com/en/docs/twitter-for-websites/cards/guides/getting-started // Standard meta tags - https://www.w3schools.com/tags/tag_meta.asp + // Standard time tag - https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time // Each Entry field mapping defines a list of possible tags names that contains the expected value static $meta_mappings = [ @@ -323,16 +333,16 @@ class CssSelectorBridge extends BridgeAbstract 'uri' => [ 'og:url', 'twitter:url', - 'canonical' + 'canonical', ], 'title' => [ 'og:title', - 'twitter:title' + 'twitter:title', ], 'content' => [ 'og:description', 'twitter:description', - 'description' + 'description', ], 'timestamp' => [ 'article:published_time', @@ -342,7 +352,8 @@ class CssSelectorBridge extends BridgeAbstract 'article:modified_time', 'og:article:modified_time', 'lastModified', - 'lastmodified' + 'lastmodified', + 'time', ], 'enclosures' => [ 'og:image:secure_url', @@ -350,7 +361,7 @@ class CssSelectorBridge extends BridgeAbstract 'og:image', 'twitter:image', 'thumbnailImg', - 'thumbnailimg' + 'thumbnailimg', ], 'author' => [ 'article:author', @@ -375,6 +386,8 @@ class CssSelectorBridge extends BridgeAbstract $element = null; if ($field === 'canonical') { $element = $entry_html->find('link[rel=canonical]'); + } else if ($field === 'time') { + $element = $entry_html->find('time[datetime]'); } else { $element = $entry_html->find("meta[property=$field], meta[name=$field]"); } @@ -384,6 +397,8 @@ class CssSelectorBridge extends BridgeAbstract $field_value = ''; if ($field === 'canonical') { $field_value = $element->href; + } else if ($field === 'time') { + $field_value = $element->datetime; } else { $field_value = $element->content; } diff --git a/bridges/CssSelectorFeedExpanderBridge.php b/bridges/CssSelectorFeedExpanderBridge.php index 49bbd473..c4763a86 100644 --- a/bridges/CssSelectorFeedExpanderBridge.php +++ b/bridges/CssSelectorFeedExpanderBridge.php @@ -37,6 +37,11 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge 'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.', 'type' => 'checkbox', ], + 'thumbnail_as_header' => [ + 'name' => '[Optional] Insert thumbnail as article header', + 'title' => 'Insert article main image on top of article contents.', + 'type' => 'checkbox', + ], 'limit' => self::LIMIT ] ]; @@ -48,6 +53,7 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge $content_cleanup = $this->getInput('content_cleanup'); $dont_expand_metadata = $this->getInput('dont_expand_metadata'); $discard_thumbnail = $this->getInput('discard_thumbnail'); + $thumbnail_as_header = $this->getInput('thumbnail_as_header'); $limit = $this->getInput('limit'); $feedParser = new FeedParser(); @@ -100,6 +106,13 @@ class CssSelectorFeedExpanderBridge extends CssSelectorBridge unset($item_expanded['enclosures']); } + if ($thumbnail_as_header && isset($item_expanded['enclosures'][0])) { + $item_expanded['content'] = '

' + . $item_expanded['content']; + } + $this->items[] = $item_expanded; } } diff --git a/bridges/SitemapBridge.php b/bridges/SitemapBridge.php index bbbb3e16..071cb0ef 100644 --- a/bridges/SitemapBridge.php +++ b/bridges/SitemapBridge.php @@ -58,6 +58,11 @@ class SitemapBridge extends CssSelectorBridge 'title' => 'Some sites set their logo as thumbnail for every article. Use this option to discard it.', 'type' => 'checkbox', ], + 'thumbnail_as_header' => [ + 'name' => '[Optional] Insert thumbnail as article header', + 'title' => 'Insert article main image on top of article contents.', + 'type' => 'checkbox', + ], 'limit' => self::LIMIT ] ]; @@ -71,6 +76,7 @@ class SitemapBridge extends CssSelectorBridge $title_cleanup = $this->getInput('title_cleanup'); $site_map = $this->getInput('site_map'); $discard_thumbnail = $this->getInput('discard_thumbnail'); + $thumbnail_as_header = $this->getInput('thumbnail_as_header'); $limit = $this->getInput('limit'); $this->feedName = $this->titleCleanup($this->getPageTitle($this->homepageUrl), $title_cleanup); @@ -87,6 +93,9 @@ class SitemapBridge extends CssSelectorBridge if ($discard_thumbnail && isset($item['enclosures'])) { unset($item['enclosures']); } + if ($thumbnail_as_header && isset($item['enclosures'])) { + $item['content'] = '

' . $item['content']; + } $this->items[] = $item; } }