Documentation

CssLoader
in package

Table of Contents

Properties

$assetFetcher  : AssetFetcher
$cache  : Cache
$mpdf  : Mpdf

Methods

__construct()  : mixed
extractExternalStylesheetUrls()  : array<string|int, mixed>
Extract external stylesheet URLs from HTML.
loadStylesheet()  : string
Fetch and return the CSS from $path
processDataUriImages()  : string
Process data URI images in CSS.
processExternalCssImports()  : string
Locate embedded @import stylesheets in other stylesheets and fix url paths (including background-images) relative to stylesheet
resolveBackgroundUrls()  : string
Resolve background image URLs in CSS.

Properties

Methods

extractExternalStylesheetUrls()

Extract external stylesheet URLs from HTML.

public extractExternalStylesheetUrls(string $html) : array<string|int, mixed>

Finds all external CSS file references including:

  • @import url(...)
  • @import "..."
Parameters
$html : string

HTML content to scan

Return values
array<string|int, mixed>

Array of CSS file URLs

loadStylesheet()

Fetch and return the CSS from $path

public loadStylesheet(string $path) : string
Parameters
$path : string
Tags
throws
MpdfException

If asset fetching issue, is through when $mpdf->debug = true

Return values
string

processDataUriImages()

Process data URI images in CSS.

public processDataUriImages(string $cssStr) : string

Converts data URI images to temporary files for processing. Example: url(data:image/png;base64,...) becomes url("tempfile.png")

Parameters
$cssStr : string

CSS string potentially containing data URIs

Tags
throws
RandomException
Return values
string

CSS string with data URIs replaced by temp file references

processExternalCssImports()

Locate embedded @import stylesheets in other stylesheets and fix url paths (including background-images) relative to stylesheet

public processExternalCssImports(string $stylesheetCss, string $path, array<string|int, mixed> &$externalCss, int &$externalCssCount) : string
Parameters
$stylesheetCss : string
$path : string
$externalCss : array<string|int, mixed>
$externalCssCount : int
Return values
string

resolveBackgroundUrls()

Resolve background image URLs in CSS.

public resolveBackgroundUrls(string $cssStr[, string|null $basePath = null ]) : string

Converts relative URLs to absolute paths using Path::relativeToAbsolute. Skips data URIs which are already absolute.

Parameters
$cssStr : string

CSS string potentially containing background URLs

$basePath : string|null = null

Optional base path for resolving relative URLs

Return values
string

CSS string with resolved URLs


        
On this page

Search results