From 8b2fdb3937aabb9d7031ad068a646c8e3b637265 Mon Sep 17 00:00:00 2001 From: Teromene Date: Fri, 3 Mar 2017 14:13:29 +0000 Subject: [PATCH] Add a function to convert the background-image attribute to an actual image. --- lib/html.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/html.php b/lib/html.php index d5f6667..ed1b394 100644 --- a/lib/html.php +++ b/lib/html.php @@ -278,6 +278,25 @@ $keptText = array()){ return $htmlContent; } +function backgroundToImg($htmlContent) { + + $regex = '/background-image[ ]{0,}:[ ]{0,}url\([\'"]{0,}(.*?)[\'"]{0,}\)/'; + $htmlContent = str_get_html($htmlContent); + + foreach($htmlContent->find('*[!b38fd2b1fe7f4747d6b1c1254ccd055e]') as $element) { + + if(preg_match($regex, $element->style, $matches) > 0) { + + $element->outertext = ''; + + } + + } + + return $htmlContent; + +} + function defaultLinkTo($content, $server){ foreach($content->find('img') as $image){ if(strpos($image->src, 'http') === false