Flutter_html: a href with image

Created on 10 Jul 2019  路  12Comments  路  Source: Sub6Resources/flutter_html

Good morning,

a image as a link is not clickable.
<a href="www.google.de"><img src="https://image.de"></a>

can you fix it? =)

kind regards

bug richtext-parser

Most helpful comment

Yup, this is definitely an issue. I'll work to make sure that the onLinkTap callback is preferred over the onImageTap in this case.

All 12 comments

Hey can you please post your code of the Html Widget.

Html( linkStyle: TextStyle(color: Colors.grey), data: deal.content, defaultTextStyle: Styles.BLACK_MEDIUM_16, onLinkTap: (url) => launch(url), ),

Same problem here, a href with image when is clicked fires onImageTap event and not onLinkTap.

Yup, this is definitely an issue. I'll work to make sure that the onLinkTap callback is preferred over the onImageTap in this case.

I have the same issue. Hopefully the fix can be released soon. Currently I'm using a complicated workaround. Thanks a lot!

This issue exists in the default parser as well as the RichText parser.

@Sub6Resources - this issue is really unfortunate because the current onImageTap callback only provides the image URL that is clicked. Often times, an image is used as a button or CTA and needs to open another URL. Would you consider prioritizing this issue?

Currently, the only workaround I can think of is adding the open url to a query parameter and extracting that value.

This has been fixed in version 1.0.0 and will be released by the end of the month. See #122 for progress on the 1.0.0 release.

As a note, the fix makes it so that _both_ of the callbacks (onImageTap and onLinkTap) are called.

@Sub6Resources thanks for the fix! Is there a way to suppress onImageTap in this case? Alternatively is there a way to detect this case in onImageTap to suppress it there?

Not currently, I may consider adding that though. What is your use-case for detecting onLinkTap and suppressing onImageTap?

I have user content, namely I render parsed markdown content. Users sometimes embed images which I'd like to provide a lightbox for on tap. But sometimes users also wrap the image embed with a link for example for a link banner or a link to their own gallery page etc. In this case I want to open just the link and not show the lightbox.

Guess I should open a new issue for the above so it doesn't get lost?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AbdoXLabs picture AbdoXLabs  路  5Comments

The-Redhat picture The-Redhat  路  3Comments

Larpoux picture Larpoux  路  3Comments

freddoOswaldo picture freddoOswaldo  路  4Comments

munnadroid picture munnadroid  路  6Comments