fix: preserve inline CSS background images - #2223
Open
itsafal wants to merge 4 commits into
Open
Conversation
Release v0.9.3
docs: credit Jace Sun by GitHub handle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Related to #1691. Crawl4AI currently omits image URLs declared in inline CSS
backgroundandbackground-imageproperties from its normal media and Markdown outputs.This PR takes a deliberately narrow approach: it handles inline
styleattributes and routes the discovered URLs through the existing<img>extraction pipeline. It does not add computed-style extraction, external stylesheet parsing, new configuration, or new media models.media.images,cleaned_html, and Markdown.data:,blob:, andjavascript:URLs.This is intentionally smaller than the broader, previously closed CSS-background proposal in #1702, minimizing changes across the crawler pipeline while addressing the common inline-style case.
List of files changed and why
crawl4ai/content_scraping_strategy.py- Extract inline CSS background URLs and route them through normal image processing.tests/test_css_background_images.py- Add regression coverage for extraction, Markdown, exclusions, URL handling, parser edge cases, and deduplication.How Has This Been Tested?
uv run --with pytest --with nest_asyncio --with tabulate pytest -q tests/test_css_background_images.py tests/test_issue_1484_css_selector.py tests/test_issue_1043_mermaid_svg.py(34 passed)git diff --checkChecklist: