Skip to content

Commit 9d25e1f

Browse files
committed
Use the supplied predicate to filter out captions
1 parent 51a4c31 commit 9d25e1f

File tree

1 file changed

+3
-1
lines changed
  • wordpress-shortcodes/src/main/java/org/wordpress/aztec/plugins/shortcodes/extensions

1 file changed

+3
-1
lines changed

wordpress-shortcodes/src/main/java/org/wordpress/aztec/plugins/shortcodes/extensions/CaptionExtensions.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ fun AztecText.hasImageCaption(attributePredicate: AztecText.AttributePredicate):
4747
this.text.getSpans(0, this.text.length, AztecImageSpan::class.java)
4848
.firstOrNull {
4949
val wrapper = SpanWrapper<AztecImageSpan>(text, it)
50-
return text.getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan::class.java).isNotEmpty()
50+
return text.getSpans(wrapper.start, wrapper.end, CaptionShortcodeSpan::class.java)
51+
.map { span -> span as CaptionShortcodeSpan }
52+
.any { span -> attributePredicate.matches(span.attributes) }
5153
}
5254

5355
return false

0 commit comments

Comments
 (0)