Problem/Motivation

Currently the photoswipe logic just loops over all elements in the DOM which are an img node. If a content editor in the CKEditor already added a link around the image (a tag) you end up with an A tag in an A tag which is malformed HTML. The browser will try to correct this by putting the first A tag above the other elements, but this results in the content editors link not working.

The end game would be #3546923: Make the swiper toggle-able in CKEditor, but I think this is a great in between step.

Steps to reproduce

In a photoswipe enabled CKEditor, upload an image and add in the ckeditor a link to https://google.com. Observe the rendered HTML.

Proposed resolution

Check all parents if there is an A tag already around the DOM element. If present we skip the photo swipe logic.

Remaining tasks

MR

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

bramdriesen created an issue. See original summary.

bramdriesen’s picture

Status: Active » Needs review
ivnish’s picture

Could you add a simple test? :)

bramdriesen’s picture

Done

  • ivnish committed 165ac047 on 1.0.x authored by bramdriesen
    fix: #3560724 Malformed HTML when <a/> tag is already present
    
    By:...
ivnish’s picture

Assigned: bramdriesen » Unassigned
Status: Needs review » Fixed

Merged! Thank you!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.