From 077fc4bc3c24f772fe18285363ad1725afbee27a Mon Sep 17 00:00:00 2001 From: Tone <66808319+Tone866@users.noreply.github.com> Date: Tue, 17 Jan 2023 17:01:09 +0100 Subject: [PATCH] Update HeiseBridge.php (#3214) loading smaller images instead the original ones with a size of around 20Mb --- bridges/HeiseBridge.php | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/bridges/HeiseBridge.php b/bridges/HeiseBridge.php index dbada64c..bb4516f5 100644 --- a/bridges/HeiseBridge.php +++ b/bridges/HeiseBridge.php @@ -61,19 +61,11 @@ class HeiseBridge extends FeedExpander private function addArticleToItem($item, $article) { - // copy full-res img src to standard img element - foreach ($article->find('a-img') as $aimg) { - $img = $aimg->find('img', 0); - $img->src = $aimg->src; - // client scales based on aspect ratio in style attribute - $img->width = ''; - $img->height = ''; - } // relink URIs, as the previous a-img tags weren't recognized by this function $article = defaultLinkTo($article, $item['uri']); // remove unwanted stuff - foreach ($article->find('figure.branding, a-ad, div.ho-text, noscript img, .opt-in__content-container') as $element) { + foreach ($article->find('figure.branding, a-ad, div.ho-text, a-img, .opt-in__content-container') as $element) { $element->remove(); } // reload html, as remove() is buggy @@ -81,7 +73,7 @@ class HeiseBridge extends FeedExpander $header = $article->find('header.a-article-header', 0); if ($header) { - $headerElements = $header->find('p, a-img img, figure img'); + $headerElements = $header->find('p, figure img, noscript img'); $item['content'] = implode('', $headerElements); $authors = $header->find('.a-creator__names .a-creator__name'); @@ -95,13 +87,10 @@ class HeiseBridge extends FeedExpander $content = $article->find('.article-content', 0); if ($content) { $contentElements = $content->find( - 'p, h3, ul, table, pre, a-img img, a-bilderstrecke h2, a-bilderstrecke figure, a-bilderstrecke figcaption' + 'p, h3, ul, table, pre, noscript img, a-bilderstrecke h2, a-bilderstrecke figure, a-bilderstrecke figcaption' ); $item['content'] .= implode('', $contentElements); - } - foreach ($article->find('a-img img, a-bilderstrecke img, figure img') as $img) { - $item['enclosures'][] = $img->src; - } + } return $item; }