Skip to content

Commit 29673ed

Browse files
committed
Fix ImageWithCaptionAdapter.kt
1 parent a0f4367 commit 29673ed

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

media-placeholders/src/main/java/org/wordpress/aztec/placeholders/ImageWithCaptionAdapter.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,17 @@ class ImageWithCaptionAdapter(
8282
private const val SRC_ATTRIBUTE = "src"
8383

8484
suspend fun insertImageWithCaption(placeholderManager: PlaceholderManager, src: String, caption: String) {
85-
placeholderManager.insertOrUpdateItem(ADAPTER_TYPE) { currentAttributes, type ->
85+
placeholderManager.insertOrUpdateItem(ADAPTER_TYPE) { currentAttributes, type, placeAtStart ->
8686
if (currentAttributes == null || type != ADAPTER_TYPE) {
8787
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to caption)
8888
} else {
8989
val currentCaption = currentAttributes[CAPTION_ATTRIBUTE]
90-
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to "$caption - $currentCaption")
90+
val newCaption = if (placeAtStart) {
91+
"$caption - $currentCaption"
92+
} else {
93+
"$currentCaption - $caption"
94+
}
95+
mapOf(SRC_ATTRIBUTE to src, CAPTION_ATTRIBUTE to newCaption)
9196
}
9297
}
9398
}

0 commit comments

Comments
 (0)