Treat animated gifs different from regular video
This commit is contained in:
parent
5338cd88fe
commit
6f42628428
|
@ -109,12 +109,25 @@ final class RedditLinkData: Codable {
|
||||||
if let width = media?.video?.width, let height = media?.video?.height {
|
if let width = media?.video?.width, let height = media?.video?.height {
|
||||||
html += "width=\"\(width)\" height=\"\(height)\" "
|
html += "width=\"\(width)\" height=\"\(height)\" "
|
||||||
}
|
}
|
||||||
html += "src=\"\(videoURL)\" autoplay muted loop></video>"
|
html += "src=\"\(videoURL)\"></video>"
|
||||||
|
return html
|
||||||
|
}
|
||||||
|
|
||||||
|
if let imageVariantURL = preview?.images?.first?.variants?.mp4?.source?.url {
|
||||||
|
var html = "<video class=\"nnwAnimatedGIF\" "
|
||||||
|
if let previewImageURL = preview?.images?.first?.source?.url {
|
||||||
|
html += "poster=\"\(previewImageURL)\" "
|
||||||
|
}
|
||||||
|
if let width = preview?.images?.first?.variants?.mp4?.source?.width, let height = preview?.images?.first?.variants?.mp4?.source?.height {
|
||||||
|
html += "width=\"\(width)\" height=\"\(height)\" "
|
||||||
|
}
|
||||||
|
html += "src=\"\(imageVariantURL)\" autoplay muted loop></video>"
|
||||||
|
html += linkURL(url)
|
||||||
return html
|
return html
|
||||||
}
|
}
|
||||||
|
|
||||||
if let videoPreviewURL = preview?.videoPreview?.url {
|
if let videoPreviewURL = preview?.videoPreview?.url {
|
||||||
var html = "<video "
|
var html = "<video class=\"nnwAnimatedGIF\" "
|
||||||
if let previewImageURL = preview?.images?.first?.source?.url {
|
if let previewImageURL = preview?.images?.first?.source?.url {
|
||||||
html += "poster=\"\(previewImageURL)\" "
|
html += "poster=\"\(previewImageURL)\" "
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,42 @@ struct RedditPreview: Codable {
|
||||||
struct RedditPreviewImage: Codable {
|
struct RedditPreviewImage: Codable {
|
||||||
|
|
||||||
let source: RedditPreviewImageSource?
|
let source: RedditPreviewImageSource?
|
||||||
|
let variants: RedditPreviewImageVariants?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case source = "source"
|
||||||
|
case variants = "variants"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RedditPreviewImageSource: Codable {
|
||||||
|
|
||||||
|
let url: String?
|
||||||
|
let width: Int?
|
||||||
|
let height: Int?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case url = "url"
|
||||||
|
case width = "width"
|
||||||
|
case height = "height"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RedditPreviewImageVariants: Codable {
|
||||||
|
|
||||||
|
let mp4: RedditPreviewImageVariantsMP4?
|
||||||
|
|
||||||
|
enum CodingKeys: String, CodingKey {
|
||||||
|
case mp4 = "mp4"
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
struct RedditPreviewImageVariantsMP4: Codable {
|
||||||
|
|
||||||
|
let source: RedditPreviewImageVariantsMP4Source?
|
||||||
|
|
||||||
enum CodingKeys: String, CodingKey {
|
enum CodingKeys: String, CodingKey {
|
||||||
case source = "source"
|
case source = "source"
|
||||||
|
@ -30,7 +66,7 @@ struct RedditPreviewImage: Codable {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct RedditPreviewImageSource: Codable {
|
struct RedditPreviewImageVariantsMP4Source: Codable {
|
||||||
|
|
||||||
let url: String?
|
let url: String?
|
||||||
let width: Int?
|
let width: Int?
|
||||||
|
|
Loading…
Reference in New Issue