diff --git a/CHANGELOG.md b/CHANGELOG.md
index 79a9fe82..1a447b1a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,14 @@
# SNAPSHOT
#### Changed
-* `image-glide`: update to `4.11.0` version
-* `inline-parser`: revert parsing index when `InlineProcessor` returns `null` as result
+* `image-glide` - update to `4.11.0` version
+* `inline-parser` - revert parsing index when `InlineProcessor` returns `null` as result
+* `image-coil` - update `Coil` to `0.12.0` ([Coil changelog](https://coil-kt.github.io/coil/changelog/)) ([#284])
Thanks [@magnusvs]
+
+[#284]: https://github.com/noties/Markwon/pull/284
+
+[@magnusvs]: https://github.com/magnusvs
+
# 4.5.1
@@ -16,7 +22,7 @@
* `ext-tables` - fix column width rounding issue
[#272]: https://github.com/noties/Markwon/issues/272
-[#274]: https://github.com/noties/Markwon/issues/274
+[#274]: https://github.com/noties/Markwon/issues/274
# 4.5.0
diff --git a/app-sample/samples.json b/app-sample/samples.json
index 1f2a8995..bbc13734 100644
--- a/app-sample/samples.json
+++ b/app-sample/samples.json
@@ -1,4 +1,16 @@
[
+ {
+ "javaClassName": "io.noties.markwon.app.samples.image.CoilImageSample",
+ "id": "20200826101209",
+ "title": "Coil image",
+ "description": "",
+ "artifacts": [
+ "IMAGE_COIL"
+ ],
+ "tags": [
+ "image"
+ ]
+ },
{
"javaClassName": "io.noties.markwon.app.samples.JustifyModeSample",
"id": "20200826084338",
diff --git a/app-sample/src/main/java/io/noties/markwon/app/samples/image/CoilImageSample.kt b/app-sample/src/main/java/io/noties/markwon/app/samples/image/CoilImageSample.kt
new file mode 100644
index 00000000..1b068dca
--- /dev/null
+++ b/app-sample/src/main/java/io/noties/markwon/app/samples/image/CoilImageSample.kt
@@ -0,0 +1,93 @@
+package io.noties.markwon.app.samples.image
+
+import coil.ImageLoader
+import coil.request.Disposable
+import coil.request.ImageRequest
+import coil.transform.CircleCropTransformation
+import io.noties.markwon.Markwon
+import io.noties.markwon.app.sample.Tags
+import io.noties.markwon.app.sample.ui.MarkwonTextViewSample
+import io.noties.markwon.image.AsyncDrawable
+import io.noties.markwon.image.coil.CoilImagesPlugin
+import io.noties.markwon.sample.annotations.MarkwonArtifact
+import io.noties.markwon.sample.annotations.MarkwonSampleInfo
+
+@MarkwonSampleInfo(
+ id = "20200826101209",
+ title = "Coil image",
+ artifacts = [MarkwonArtifact.IMAGE_COIL],
+ tags = [Tags.image]
+)
+class CoilImageSample : MarkwonTextViewSample() {
+ override fun render() {
+ val md = """
+ # H1
+ ## H2
+ ### H3
+ #### H4
+ ##### H5
+
+ > a quote
+
+ + one
+ - two
+ * three
+
+ 1. one
+ 1. two
+ 1. three
+
+ ---
+
+ # Images
+
+ 
+ """.trimIndent()
+
+ // pick one
+ val markwon = Markwon.builder(context)
+// .usePlugin(coilPlugin1)
+// .usePlugin(coilPlugin2)
+ .usePlugin(coilPlugin3)
+ .build()
+
+ markwon.setMarkdown(textView, md)
+ }
+
+ val coilPlugin1: CoilImagesPlugin
+ get() = CoilImagesPlugin.create(context)
+
+ val coilPlugin2: CoilImagesPlugin
+ get() = CoilImagesPlugin.create(context, imageLoader)
+
+ val coilPlugin3: CoilImagesPlugin
+ get() {
+ val loader = imageLoader
+ return CoilImagesPlugin.create(
+ object : CoilImagesPlugin.CoilStore {
+ override fun load(drawable: AsyncDrawable): ImageRequest {
+ return ImageRequest.Builder(context)
+ .defaults(loader.defaults)
+ .data(drawable.destination)
+ .crossfade(true)
+ .transformations(CircleCropTransformation())
+ .build()
+ }
+
+ override fun cancel(disposable: Disposable) {
+ disposable.dispose()
+ }
+ },
+ loader
+ )
+ }
+
+ val imageLoader: ImageLoader
+ get() = ImageLoader.Builder(context)
+ .apply {
+ availableMemoryPercentage(0.5)
+ bitmapPoolPercentage(0.5)
+ crossfade(true)
+ }
+ .build()
+}
\ No newline at end of file
diff --git a/docs/docs/v4/image-coil/README.md b/docs/docs/v4/image-coil/README.md
index 3e9a918b..9a1a0d5f 100644
--- a/docs/docs/v4/image-coil/README.md
+++ b/docs/docs/v4/image-coil/README.md
@@ -2,39 +2,73 @@
-Image loading based on `Coil` library.
+Image loading based on [Coil](https://github.com/coil-kt/coil/) library.
+
+There are 3 factory methods to obtain `CoilImagesPlugin`:
```kotlin
-val markwon = Markwon.builder(context)
- // automatically create Coil instance
- .usePlugin(CoilImagesPlugin.create(context))
- // use supplied ImageLoader instance
- .usePlugin(CoilImagesPlugin.create(
- context,
- ImageLoader(context) {
- availableMemoryPercentage(0.5)
- bitmapPoolPercentage(0.5)
- crossfade(true)
- }
- ))
- // if you need more control
- .usePlugin(CoilImagesPlugin.create(object : CoilImagesPlugin.CoilStore {
- override fun load(drawable: AsyncDrawable): LoadRequest {
- return LoadRequest(context, customImageLoader.defaults) {
- data(drawable.destination)
- crossfade(true)
- transformations(CircleCropTransformation())
- }
- }
-
- override cancel(disposable: RequestDisposable) {
- disposable.dispose()
- }
- }, customImageLoader))
- .build()
+val coilPlugin: CoilImagesPlugin
+ get() = CoilImagesPlugin.create(context)
```
:::warning
In order to use the `CoilImagesPlugin.create(Context)` factory method your
-app must have **explicit** dependency on `coil` library
-:::
\ No newline at end of file
+app must have **explicit** dependency on `coil` (`io.coil-kt:coil`) library. This artifact
+relies on `io.coil-kt:coil-base` as per [Coil documentation](https://coil-kt.github.io/coil/getting_started/#artifacts)
+:::
+
+```kotlin
+val coilPlugin: CoilImagesPlugin
+ get() = CoilImagesPlugin.create(context, imageLoader)
+
+val imageLoader: ImageLoader
+ get() = ImageLoader.Builder(context)
+ .apply {
+ availableMemoryPercentage(0.5)
+ bitmapPoolPercentage(0.5)
+ crossfade(true)
+ }
+ .build()
+```
+
+```kotlin
+val coilPlugin: CoilImagesPlugin
+ get() {
+ val loader = imageLoader
+ return CoilImagesPlugin.create(
+ object : CoilImagesPlugin.CoilStore {
+ override fun load(drawable: AsyncDrawable): ImageRequest {
+ return ImageRequest.Builder(context)
+ .defaults(loader.defaults)
+ .data(drawable.destination)
+ .crossfade(true)
+ .transformations(CircleCropTransformation())
+ .build()
+ }
+
+ override fun cancel(disposable: Disposable) {
+ disposable.dispose()
+ }
+ },
+ loader
+ )
+ }
+
+val imageLoader: ImageLoader
+ get() = ImageLoader.Builder(context)
+ .apply {
+ availableMemoryPercentage(0.5)
+ bitmapPoolPercentage(0.5)
+ crossfade(true)
+ }
+ .build()
+```
+
+Finally, use as a regular plugin:
+
+```kotlin
+val markwon = Markwon.builder(context)
+ .usePlugin(coilPlugin)
+ .build()
+
+```