mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-01-28 01:39:47 +01:00
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 {
|
||||
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
|
||||
}
|
||||
|
||||
if let videoPreviewURL = preview?.videoPreview?.url {
|
||||
var html = "<video "
|
||||
var html = "<video class=\"nnwAnimatedGIF\" "
|
||||
if let previewImageURL = preview?.images?.first?.source?.url {
|
||||
html += "poster=\"\(previewImageURL)\" "
|
||||
}
|
||||
|
@ -23,6 +23,42 @@ struct RedditPreview: Codable {
|
||||
struct RedditPreviewImage: Codable {
|
||||
|
||||
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 {
|
||||
case source = "source"
|
||||
@ -30,7 +66,7 @@ struct RedditPreviewImage: Codable {
|
||||
|
||||
}
|
||||
|
||||
struct RedditPreviewImageSource: Codable {
|
||||
struct RedditPreviewImageVariantsMP4Source: Codable {
|
||||
|
||||
let url: String?
|
||||
let width: Int?
|
||||
|
Loading…
x
Reference in New Issue
Block a user