-
-
Notifications
You must be signed in to change notification settings - Fork 967
Open
Description
Description
I found a bug where the PhotoSwipe script (_includes/extensions/photo-swipe.html
) wraps all <img>
elements (except those with emoji
class) in a new <a class="photo-swipe">
element, including images that are already inside a link. This causes the original link functionality to be lost.
Current Behavior
When an image is already wrapped in a link like this:
<a href="https://example.com">
<img src="image.jpg">
</a>
The script wraps it again, resulting in:
<a href="https://example.com">
<a class="photo-swipe" href="image.jpg" ...>
<img src="image.jpg">
</a>
</a>
The original link to https://example.com
becomes inaccessible.
Expected Behavior
Images that are already inside <a>
tags should be skipped by the script to preserve their original link functionality.
Steps to Reproduce
- Create a post with a linked image:
<a href="https://example.com"><img src="image.jpg"></a>
- Load the page with PhotoSwipe enabled
- Click the image
- PhotoSwipe opens instead of following the original link
Proposed Solution
I believe this can be fixed by adding a check to skip images whose parent element is already an <a>
tag. I'd be happy to submit a pull request with this fix if you'd like.
Metadata
Metadata
Assignees
Labels
No labels