diff --git a/bindings/php/stubs/css_inline.php b/bindings/php/stubs/css_inline.php index f3c6230b..6002c094 100644 --- a/bindings/php/stubs/css_inline.php +++ b/bindings/php/stubs/css_inline.php @@ -68,6 +68,8 @@ class CssInliner * @param int $preallocateNodeCapacity Pre-allocate capacity for HTML nodes * @param StylesheetCache|null $cache Cache for external stylesheets * @param bool $removeInlinedSelectors Remove selectors that were successfully inlined from style blocks + * @param bool $applyWidthAttributes Add width HTML attributes from CSS width properties on supported elements + * @param bool $applyHeightAttributes Add height HTML attributes from CSS height properties on supported elements */ public function __construct( bool $inlineStyleTags = true, @@ -81,6 +83,8 @@ public function __construct( int $preallocateNodeCapacity = 32, ?StylesheetCache $cache = null, bool $removeInlinedSelectors = false, + bool $applyWidthAttributes = false, + bool $applyHeightAttributes = false, ) {} /** diff --git a/bindings/php/tests/CssInlineTest.php b/bindings/php/tests/CssInlineTest.php index d2a16008..531d0825 100644 --- a/bindings/php/tests/CssInlineTest.php +++ b/bindings/php/tests/CssInlineTest.php @@ -276,6 +276,30 @@ public function testLoadRemoteStylesheetsDisabled(): void $this->assertIsString($result); } + public function testApplyWidthAttributes(): void + { + $inliner = new CssInliner( + applyWidthAttributes: true, + ); + + $html = '
Test
'; + $result = $inliner->inline($html); + + $this->assertStringContainsString('width="100"', $result); + } + + public function testApplyHeightAttributes(): void + { + $inliner = new CssInliner( + applyHeightAttributes: true, + ); + + $html = '
Test
'; + $result = $inliner->inline($html); + + $this->assertStringContainsString('height="50"', $result); + } + public function testRemoveInlinedSelectors(): void { $inliner = new CssInliner(