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`)
|
* Blockquote (`blockquote`)
|
||||||
* Heading (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`)
|
* Heading (`h1`, `h2`, `h3`, `h4`, `h5`, `h6`)
|
||||||
* there is support to render any HTML tag, but it will require to create a special `TagHandler`,
|
* 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/):
|
* [Task lists](/docs/v3/ext-tasklist/):
|
||||||
- [ ] Not _done_
|
- [ ] Not _done_
|
||||||
- [X] **Done** with `X`
|
- [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.
|
and [image-svg](/docs/v3/image/svg.md) modules.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
##
|
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
If you are using [html](/docs/v3/html/) you do not have to additionally setup
|
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
|
images displayed via `<img>` tag, as `HtmlPlugin` automatically uses configured
|
||||||
@ -156,4 +154,52 @@ sizes, which is not supported natively by markdown, allowing absolute or relativ
|
|||||||
```html
|
```html
|
||||||
<img src="./assets/my-image" width="100%">
|
<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.
|
||||||
|
:::
|
||||||
|
@ -7,4 +7,6 @@
|
|||||||
* * OkHttpClient to download images moved to standalone module
|
* * OkHttpClient to download images moved to standalone module
|
||||||
* HTML no longer _implicitly_ added to core functionality, it must be specified __explicitly__ (as an artifact)
|
* HTML no longer _implicitly_ added to core functionality, it must be specified __explicitly__ (as an artifact)
|
||||||
* removed `markwon-view` module
|
* removed `markwon-view` module
|
||||||
* changed Maven artifacts group to `ru.noties.markwon`
|
* 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