// Check for global @embed comment and remove it. Allow other comments to be present
// before @embed (they have been replaced with placeholders at this point).
$embedAll = false;
- $rule = preg_replace( '/^((?:\s+|' . CSSMin::PLACEHOLDER . '(\d+)x)*)' . CSSMin::EMBED_REGEX . '\s*/', '$1', $rule, 1, $embedAll );
+ $rule = preg_replace(
+ '/^((?:\s+|' .
+ CSSMin::PLACEHOLDER .
+ '(\d+)x)*)' .
+ CSSMin::EMBED_REGEX .
+ '\s*/',
+ '$1',
+ $rule,
+ 1,
+ $embedAll
+ );
// Build two versions of current rule: with remapped URLs
// and with embedded data: URIs (where possible).
// Path to the actual file on the filesystem
$localFile = "{$local}/{$file}";
if ( file_exists( $localFile ) ) {
- // Add version parameter as the first five hex digits
- // of the MD5 hash of the file's contents.
- $url .= '?' . substr( md5_file( $localFile ), 0, 5 );
if ( $embed ) {
$data = self::encodeImageAsDataURI( $localFile );
if ( $data !== false ) {
return $data;
}
}
+ if ( method_exists( 'OutputPage', 'transformFilePath' ) ) {
+ $url = OutputPage::transformFilePath( $remote, $local, $file );
+ } else {
+ // Add version parameter as the first five hex digits
+ // of the MD5 hash of the file's contents.
+ $url .= '?' . substr( md5_file( $localFile ), 0, 5 );
+ }
}
// If any of these conditions failed (file missing, we don't want to embed it
// or it's not embeddable), return the URL (possibly with ?timestamp part)