Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Fix bug empty src
Browse files Browse the repository at this point in the history
  • Loading branch information
mai.tan committed Mar 19, 2019
1 parent 572fcda commit a43c674
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/DeferOptimizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,22 +319,21 @@ protected function optimizeImgTags()

if (!empty($src = $node->getAttribute(static::ATTR_SRCSET))) {
$node->setAttribute(static::ATTR_DATA_SRCSET, $src);
$node->setAttribute(static::ATTR_SRCSET, $this->empty_gif);
}

if (!empty($this->empty_gif)) {
if ($this->empty_gif != false) {
$node->setAttribute(static::ATTR_SRC, $this->empty_gif);
} else {
$node->removeAttribute(static::ATTR_SRC);
$node->removeAttribute(static::ATTR_SRCSET);
}

// Add some placeholder color
// https://github.com/axe312ger/sqip
if ($this->use_color_placeholder) {
$placeholder = 'background-color:hsl(' . rand(1, 360) . ',100%,85%);';
$style = (string) $node->getAttribute('style');
$node->setAttribute('style', $placeholder . $style);
}
// Add some placeholder color
// https://github.com/axe312ger/sqip
if ($this->use_color_placeholder) {
$placeholder = 'background-color:hsl(' . rand(1, 360) . ',100%,85%);';
$style = (string) $node->getAttribute('style');
$node->setAttribute('style', $placeholder . $style);
}
}
}
Expand Down

0 comments on commit a43c674

Please sign in to comment.