Skip to content
This repository has been archived by the owner on Apr 20, 2023. It is now read-only.

Transformer rule : img in the context of bold/h2/etc #236

Open
kevinlisota opened this issue Aug 5, 2017 · 1 comment
Open

Transformer rule : img in the context of bold/h2/etc #236

kevinlisota opened this issue Aug 5, 2017 · 1 comment

Comments

@kevinlisota
Copy link

We have many articles on our site where the process of inserting a left or right-aligned image results in markup like this:

<strong><img class="alignright wp-image-6765 size-full" title="title" src="https://mysite/wp-content/uploads/2011/04/myimage.jpg" alt="" width="216" height="109" />Inspiration for the idea hit us when</strong>: "Some more text here"

While a little awkward in terms of placement of the image HTML, it is valid and easy to create with the WordPress editor, but it throws a transformer error for "img in the context of Bold"

The issue is that you can't create a transformer rule without losing data.

            {
                "class" : "PassThroughRule",
                "selector": "//strong[descendant::img]"
            },

That rule will pass through the img element and the image displays, but the remainder of the text inside the bold <strong> tag is lost.

Without the transformer rule, you don't get the image.

In addition to bold, we often get img tags underneath an h2 or h3 element that also has text

Any way to solve this?

@timjacobi
Copy link
Contributor

This is the set of rules I have come up with to support your case. Does that help?
screen shot 2017-11-08 at 13 07 30

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

No branches or pull requests

2 participants