Skip to content

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

Open
katerynadegtyariova wants to merge 1 commit into
catalyst:MOODLE_39_STABLEfrom
katerynadegtyariova:master-fix-234-inline-background-image-picked-up
Open

Fix #234 pick up images from inline style background image#254
katerynadegtyariova wants to merge 1 commit into
catalyst:MOODLE_39_STABLEfrom
katerynadegtyariova:master-fix-234-inline-background-image-picked-up

Conversation

@katerynadegtyariova

Copy link
Copy Markdown
Contributor

Rebased patch from John Yao

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

Copy link
Copy Markdown
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
Copy Markdown
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