Skip to content

Commit

Permalink
Reformat ImageBlockProcessor after conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
irfano committed Jun 10, 2024
1 parent 1096ca6 commit 8ec54d8
Showing 1 changed file with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,25 @@ class ImageBlockProcessor(localId: String, mediaFile: MediaFile) :
val targetImg = document.select("img").first()

// if a match is found, proceed with replacement
if (targetImg != null) {
return targetImg?.let {
// replace attributes
targetImg.attr("src", remoteUrl)
it.attr("src", remoteUrl)

// replace class
targetImg.removeClass("wp-image-$localId")
targetImg.addClass("wp-image-$remoteId")
it.removeClass("wp-image-$localId")
it.addClass("wp-image-$remoteId")

return true
}

return false
true
} ?: false
}

override fun processBlockJsonAttributes(jsonAttributes: JsonObject): Boolean {
val id = jsonAttributes["id"]
if (id != null && !id.isJsonNull && id.asString == localId) {
return if (id != null && !id.isJsonNull && id.asString == localId) {
addIntPropertySafely(jsonAttributes, "id", remoteId)
return true
true
} else {
false
}
return false
}
}

0 comments on commit 8ec54d8

Please sign in to comment.