Markwon: ImagesPlugin class is missing

I’m trying to implement images in my markdown view but it seems that the ImagesPlugin.create() is missing.

image

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (7 by maintainers)

Most upvoted comments

Hello @chrisbarth01 ,

you can use special ImageSizeResolver that explicitly makes all images fit the width of the screen. How to use custom ImageSizeResolver is shown in this sample. Then you can apply 100% as width dimension, for example:

class FitWidthImageSizeResolver : ImageSizeResolverDef() {
  override fun resolveImageSize(drawable: AsyncDrawable): Rect {
    return resolveImageSize(
      ImageSize(
        ImageSize.Dimension(100F, UNIT_PERCENT),
        null
      ),
      drawable.result.bounds,
      drawable.lastKnownCanvasWidth,
      drawable.lastKnowTextSize
    )
  }
}

Hello @chrisbarth01 ,

there is a problem with the GIF that you had shared - gifer.com responds with content-type: text/plain. markwon-image relies on proper content type in order to trigger specific MediaDecoder. In this case response is decoded as a regular image (as a fallback strategy) and thus is not animated. You can try other image loaders or provide ImagesPlugin with a custom defaultMediaDecoder which handles such a case:

final Markwon markwon = Markwon.builder(context)
  .usePlugin(ImagesPlugin.create(plugin -> {
    plugin.defaultMediaDecoder(new MyGifAwareDefaultMediaDecoder());
  }))
  .build();

Other available image loaders that have GIF support are:

Hello @chrisbarth01 ,

if it is working for you in the sample app, then check your GIF:

  • is it really an animated GIF?
  • does response correctly respond with Content-Type: image/gif content type?
  • GifMediaDecoder.create() accepts an optional autoplay argument, have you tried passing an explicit true?

Hello @chrisbarth01 ,

you need the io.noties.markwon:image:$version artifact. The list of available artifacts is available in the install section of documentation