Skip to content

Rewrite CSS URLs (e.g. cover block)#243

Merged
adamziel merged 7 commits intomasterfrom
backport-php-toolkit-updates
Nov 4, 2025
Merged

Rewrite CSS URLs (e.g. cover block)#243
adamziel merged 7 commits intomasterfrom
backport-php-toolkit-updates

Conversation

@adamziel
Copy link
Contributor

@adamziel adamziel commented Nov 3, 2025

Adds support for rewriting URLs inside CSS syntax, e.g. here:

<div style="background-image:url(/wp-content/uploads/2025/09/image-2-766x1024.jpeg)">

Before this PR, the style attributes in, e.g., the cover block were skipped by the URL rewriter and continued pointing to the old site.

Fixes #223

Implementation details

This PR backports CSSProcessor, CSSURLProcessor, and a few related PRs around Unicode handling from the WordPress/php-toolkit repo:

Note the CSSProcessor and CSSURLProcessor are tested against 300 test cases containing various tricky inputs, quoted and unquoted URLs, strings, comments, unicode escape sequences, and more.

Testing instructions

This PR comes with a new test case specifically for various tricky CSS inputs. You're also welcome to try and import a WXR file that contains an inline background-image reference and confirm the URL is correctly rewritten.

cc @zaerl @bph

@adamziel adamziel merged commit 889794f into master Nov 4, 2025
24 checks passed
@adamziel adamziel deleted the backport-php-toolkit-updates branch November 4, 2025 18:51
@adamziel adamziel mentioned this pull request Nov 4, 2025
adamziel added a commit that referenced this pull request Nov 5, 2025
## Summary

Now that the importer supports [rewriting URLs in CSS](#243), let's release it.

cc @zaerl
@bph
Copy link

bph commented Nov 5, 2025

Sorry @adamziel I don't know how to test a Playground PR before the merge. It seems to be merged now, but I don't know if it's already deployed to the website....

So I tried it again with my theme demo blueprint and content and it still doesn't seem to replace the background image reference

When I click on Inspect it still shows me the localhost address.

Screenshot 2025-11-05 at 17 08 41

If you want to test it:

Please notify me, if I am just too early to check on your fix, or how I can help to debug this.

@adamziel
Copy link
Contributor Author

adamziel commented Nov 6, 2025

It was only released today and seems to work as expected now :)

@bph
Copy link

bph commented Nov 6, 2025

Yes it does! Sorry, jumped the gun...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cover block image is not imported

4 participants