flutter_html icon indicating copy to clipboard operation
flutter_html copied to clipboard

[BUG] ImageExtension builder is not executed when the image source is relative path

Open taskindrp opened this issue 1 year ago • 5 comments

Describe the bug: How to set base url correctly for relative path images?

HTML to reproduce the issue:

Html(
                  data: '<img width="10" alt="xkcd" src="/comics/commemorative_plaque.png" />',
                  onLinkTap: _launchUrl,
                  style: {
                    'img': Style(
                      width: Width(175),
                    ),
                  },
                  extensions: [
                    ImageExtension(
                      handleAssetImages: false,
                      handleDataImages: false,
                      builder: (ctx) {
                        return Image.network('https://imgs.xkcd.com${ctx.attributes['src']}');
                      },
                    ),
                  ],
                )

Expected behavior: image should be shown

Device details and Flutter/Dart/flutter_html versions: 3.0.0-beta.2

MarineGEO circle logo

taskindrp avatar Jun 14 '23 08:06 taskindrp

https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use

      builder: (extensionContext) {
        final element = extensionContext.styledElement as ImageElement;
        return CustomImage.network(
          "https://imgs.xkcd.com/${element.src}$",
        );
      }

erickok avatar Jun 14 '23 13:06 erickok

https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use

      builder: (extensionContext) {
        final element = extensionContext.styledElement as ImageElement;
        return CustomImage.network(
          "https://imgs.xkcd.com/${element.src}$",
        );
      }

From where do I import CustomImage ?

sarbazx avatar Jun 22 '23 09:06 sarbazx

https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders might help you. You can use

      builder: (extensionContext) {
        final element = extensionContext.styledElement as ImageElement;
        return CustomImage.network(
          "https://imgs.xkcd.com/${element.src}$",
        );
      }

From where do I import CustomImage ?

never mind :)

sarbazx avatar Jun 22 '23 10:06 sarbazx

https://github.com/Sub6Resources/flutter_html/wiki/Migration-Guides#customimagerenders可能对您有帮助。您可以使用

      builder: (extensionContext) {
        final element = extensionContext.styledElement as ImageElement;
        return CustomImage.network(
          "https://imgs.xkcd.com/${element.src}$",
        );
      }

从哪里导入CustomImage?

import 'package:flutter_html/src/tree/image_element.dart';

wapchief avatar Jul 17 '23 06:07 wapchief