Skip to content
This repository was archived by the owner on Apr 20, 2023. It is now read-only.
This repository was 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

Description

@kevinlisota

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?

Activity

  1. timjacobi commented on Nov 8, 2017

    @timjacobi
    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions