Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #234 pick up images from inline style background image #254

Open
wants to merge 1 commit into
base: MOODLE_39_STABLE
Choose a base branch
from

Conversation

katerynadegtyariova
Copy link
Contributor

Rebased patch from John Yao

/**
* Fetch and fixes all inline background images.
*/
private function update_inline_background_images() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


foreach ($elements as $element) {
$style = $element->getAttribute("style");
preg_match('/(?<=background-image)\s*:\s*url\s*\(\s*(\S+)\s*\);/', $style, $matches);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might work for this one use case but there will be a bunch of other similar use cases such as

background: url()

I'm wondering if it would be better to only match on the url() in the regex.

I'd also want some negative unit tests, eg make sure a url('data:xxxx') url isn not rewritten

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants