Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore img tag when using linkifier #3173

Merged
merged 1 commit into from
Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/parser/src/data/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class Post {
}

// Wrap an <a> tag on any link inside our content
article.content = linkifyHtml(article.content);
article.content = linkifyHtml(article.content, { ignoreTags: ['img'] });
tpmai22 marked this conversation as resolved.
Show resolved Hide resolved

let html;
try {
Expand Down
7 changes: 0 additions & 7 deletions src/web/src/components/Posts/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,6 @@ function handleZoom(e: MouseEvent) {
e.preventDefault();
zoomInImage(e.target);
}
// if the user clicks an anchor with an image inside, do not open the image link in a new tab.
else if (
e.target instanceof HTMLAnchorElement &&
e.target.firstChild instanceof HTMLImageElement
) {
e.preventDefault();
}
}

const PostComponent = ({ postUrl, currentPost, totalPosts }: Props) => {
Expand Down