Add a function to convert the background-image attribute to an actual image.
This commit is contained in:
parent
5d41a74067
commit
8b2fdb3937
1 changed files with 19 additions and 0 deletions
19
lib/html.php
19
lib/html.php
|
@ -278,6 +278,25 @@ $keptText = array()){
|
||||||
return $htmlContent;
|
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 = '<img style="display:block;" src="' . $matches[1] . '" />';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $htmlContent;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
function defaultLinkTo($content, $server){
|
function defaultLinkTo($content, $server){
|
||||||
foreach($content->find('img') as $image){
|
foreach($content->find('img') as $image){
|
||||||
if(strpos($image->src, 'http') === false
|
if(strpos($image->src, 'http') === false
|
||||||
|
|
Loading…
Reference in a new issue