Browse Source

Merge pull request #25 from twisterarmy/add-webp-support

add webp images support
pull/32/head twisterarmy-1.2
D4708 3 years ago committed by GitHub
parent
commit
9364892e0a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      js/interface_common.js
  2. 2
      js/twister_formatpost.js

2
js/interface_common.js

@ -1334,7 +1334,7 @@ function _startTorrentDownloadAndPreview(torrentId, previewContainer, isMedia) {
function webtorrentFilePreview(file, previewContainer, isMedia) { function webtorrentFilePreview(file, previewContainer, isMedia) {
if (!isMedia) { if (!isMedia) {
// try guessing by filename extension // try guessing by filename extension
isMedia = /^[^?]+\.(?:jpe?g|gif|png|mp4|webm|mp3|ogg|wav|)$/i.test(file.name) isMedia = /^[^?]+\.(?:jpe?g|gif|png|webp|mp4|webm|mp3|ogg|wav|)$/i.test(file.name)
} }
if (isMedia) { if (isMedia) {

2
js/twister_formatpost.js

@ -885,7 +885,7 @@ function setPostImagePreview(elem, links) {
if (!previewContainer.children().length) { if (!previewContainer.children().length) {
// is there any links to images in the post? // is there any links to images in the post?
for (var i = 0; i < links.length; i++) { for (var i = 0; i < links.length; i++) {
if (/^[^?]+\.(?:jpe?g|gif|png)$/i.test(links[i].href)) { if (/^[^?]+\.(?:jpe?g|gif|png|webp)$/i.test(links[i].href)) {
var url = proxyURL(links[i].href); var url = proxyURL(links[i].href);
previewContainer.append($('<img src="' + url + '" class="image-preview" />')); previewContainer.append($('<img src="' + url + '" class="image-preview" />'));
} }

Loading…
Cancel
Save