How do you embed images into lichess?
How do you embed images into lichess?
How do you embed images into lichess?
Yes, how do you embed images into lichess?
imgur.com
you can see where the image came from by right clicking on it and pressing 'open in new tab'
I'm not going to go digging through everything (all of the code; to understand how it works, where it is effective), nor am I going to write-up any step-by-step tutorials.
But, based on a quick search, here are two segments of code that'll help you out.
=====
From: https://github.com/lichess-org/lila/blob/master/modules/common/src/main/Markdown.scala
private val whitelist =
List(
"imgur.com",
"giphy.com",
"wikimedia.org",
"creativecommons.org",
"pexels.com",
"piqsels.com",
"freeimages.com",
"unsplash.com",
"pixabay.com",
"githubusercontent.com",
"googleusercontent.com",
"i.ibb.co",
"i.postimg.cc",
"xkcd.com",
"lichess1.org"
)
=====
From: https://github.com/lichess-org/lila/blob/master/modules/common/src/main/base/RawHtml.scala
private[this] val imgurRegex = """https?://(?:i\.)?imgur\.com/(\w+)(?:\.jpe?g|\.png|\.gif)?""".r
private[this] val giphyRegex =
"""https://(?:media\.giphy\.com/media/|giphy\.com/gifs/(?:\w+-)*)(\w+)(?:/giphy\.gif)?""".rprivate[this] def imgUrl(url: String): Option[String] =
(url match {
case imgurRegex(id) => Some(s"""https://i.imgur.com/$id.jpg""")
case giphyRegex(id) => Some(s"""https://media.giphy.com/media/$id/giphy.gif""")
case _ => None
}) map { img =>
s"""<img class="embed" src="$img" alt="$url"/>"""
}
This topic has been archived and can no longer be replied to.