diff --git a/docs/docs/v3/README.md b/docs/docs/v3/README.md index ef82ddba..b8e28b4c 100644 --- a/docs/docs/v3/README.md +++ b/docs/docs/v3/README.md @@ -50,7 +50,7 @@ listed in are supported (including support for * * Blockquote (`blockquote`) * Heading (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`) * there is support to render any HTML tag, but it will require to create a special `TagHandler`, - more information can be found in [HTML section](/docs/v3/html/custom-tag-handler.md) + more information can be found in [HTML section](/docs/v3/core/html-renderer.md) * [Task lists](/docs/v3/ext-tasklist/): - [ ] Not _done_ - [X] **Done** with `X` diff --git a/docs/docs/v3/core/images.md b/docs/docs/v3/core/images.md index 01ca81ce..4aa675e2 100644 --- a/docs/docs/v3/core/images.md +++ b/docs/docs/v3/core/images.md @@ -145,8 +145,6 @@ If you want to display GIF or SVG images also, you can use [image-gif](/docs/v3/ and [image-svg](/docs/v3/image/svg.md) modules. ::: -## - :::tip If you are using [html](/docs/v3/html/) you do not have to additionally setup images displayed via `` tag, as `HtmlPlugin` automatically uses configured @@ -156,4 +154,52 @@ sizes, which is not supported natively by markdown, allowing absolute or relativ ```html ``` -::: \ No newline at end of file +::: + +## Placeholder drawable + +It's possible to provide a custom placeholder for an image (whilst it's loading). + +```java +final Markwon markwon = Markwon.builder(context) + .usePlugin(ImagesPlugin.create(context)) + .usePlugin(new AbstractMarkwonPlugin() { + @Override + public void configureImages(@NonNull AsyncDrawableLoader.Builder builder) { + builder.placeholderDrawableProvider(new AsyncDrawableLoader.DrawableProvider() { + @Override + public Drawable provide() { + // your custom placeholder drawable + return new PlaceholderDrawable(); + } + }); + } + }); +``` + +## Error drawable + +To fallback in case of error whilst loading an image, an `error drawable` can be used: + + +```java +final Markwon markwon = Markwon.builder(context) + .usePlugin(ImagesPlugin.create(context)) + .usePlugin(new AbstractMarkwonPlugin() { + @Override + public void configureImages(@NonNull AsyncDrawableLoader.Builder builder) { + builder.errorDrawableProvider(new AsyncDrawableLoader.DrawableProvider() { + @Override + public Drawable provide() { + // your custom error drawable + return new MyErrorDrawable(); + } + }); + } + }); +``` + +:::warning +Before `3.0.0` `AsyncDrawableLoader` accepted a simple `Drawable` as error drawable +argument. Starting `3.0.0` it accepts a `DrawableProvider` instead. +::: diff --git a/docs/docs/v3/migration-2-3.md b/docs/docs/v3/migration-2-3.md index fbaacba7..aeb045c6 100644 --- a/docs/docs/v3/migration-2-3.md +++ b/docs/docs/v3/migration-2-3.md @@ -7,4 +7,6 @@ * * OkHttpClient to download images moved to standalone module * HTML no longer _implicitly_ added to core functionality, it must be specified __explicitly__ (as an artifact) * removed `markwon-view` module -* changed Maven artifacts group to `ru.noties.markwon` \ No newline at end of file +* changed Maven artifacts group to `ru.noties.markwon` +* removed `errorDrawable` in AsyncDrawableLoader in favor of a drawable provider +* added placeholder for AsyncDrawableProvider \ No newline at end of file