Update docs to include placeholder image functionality
This commit is contained in:
parent
50bf5b341a
commit
4514afc594
@ -50,7 +50,7 @@ listed in <Link name="commonmark-spec" /> 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`
|
||||
|
@ -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 `<img>` tag, as `HtmlPlugin` automatically uses configured
|
||||
@ -157,3 +155,51 @@ sizes, which is not supported natively by markdown, allowing absolute or relativ
|
||||
<img src="./assets/my-image" width="100%">
|
||||
```
|
||||
:::
|
||||
|
||||
## Placeholder drawable <Badge text="3.0.0" />
|
||||
|
||||
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 <Badge text="3.0.0" />
|
||||
|
||||
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.
|
||||
:::
|
||||
|
@ -8,3 +8,5 @@
|
||||
* 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`
|
||||
* removed `errorDrawable` in AsyncDrawableLoader in favor of a drawable provider
|
||||
* added placeholder for AsyncDrawableProvider
|
Loading…
x
Reference in New Issue
Block a user