+
+ def render("attachment.json", %{attachment: attachment}) do
+ [%{"mediaType" => media_type, "href" => href} | _] = attachment["url"]
+
+ type = cond do
+ String.contains?(media_type, "image") -> "image"
+ String.contains?(media_type, "video") -> "video"
+ true -> "unknown"
+ end
+
+ %{
+ id: attachment["uuid"],
+ url: href,
+ remote_url: href,
+ preview_url: href,
+ type: type
+ }
+ end