question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possibility to wrap the image in a <a> element

See original GitHub issue

Thank you for this awesome plugin.

I have a question: if we wrap this component in a <a> HTML element, we cannot hook into the Media onClick event, therefore the preventing default of the event is not happening.

Example:

<a href='/b'>
 <div which loads the image />
</a>

So the https://github.com/stereobooster/react-ideal-image/blob/master/src/components/Media/index.js#L155 could do an event prevent default.

Thank you!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
stereoboostercommented, Mar 7, 2019

Ah now I see the problem

0reactions
ioanlucutcommented, Mar 7, 2019

I have exact this case using an img inside a. I put it like this so that I can click on it and navigate, except when the image is not loaded because the user is running on 2g or so; therefore, when I click on the download image icon, the event is propagated, and instead of just downloading the image, I navigate to the href.

In this case I’d need to rewrite the entire logic in the a onClick handler (which is now in the Media component).

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - Is it possible to wrap a <picture> element inside a <a>?
I have tried wrapping this to a but this doesn't work (do not show any images). <a class="site-header ...
Read more >
How to wrap the text around an image using HTML and CSS
In HTML, we can either align the image on the right side of the text, or to the left, or to the center....
Read more >
Wrap text around any image or shape that you want! - YouTube
The first 1000 people to use the link will get a free trial of Skillshare Premium Membership: https://skl.sh/kevinpowell03211Shape-outside ...
Read more >
How to Wrap Text Around an Image With CSS - ThoughtCo
Using CSS, you can place your images on a page and then wrap the text around them. This tutorial explains how easy it...
Read more >
HTML- Text- Wrapping Text Around Images
You can position images on the page using the ALIGN attribute, and in this case, you can use the Top, Middle, or Bottom...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found