From eac88be42cc1a7f85c7a0533414e1047e0addc39 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 23 Jun 2014 18:11:59 -0400 Subject: stubbing in stuff for videos/embeds --- public/assets/javascripts/ui/lib/Parser.js | 84 ++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 21 deletions(-) (limited to 'public/assets/javascripts/ui/lib/Parser.js') diff --git a/public/assets/javascripts/ui/lib/Parser.js b/public/assets/javascripts/ui/lib/Parser.js index 705ff04..dfff7b2 100644 --- a/public/assets/javascripts/ui/lib/Parser.js +++ b/public/assets/javascripts/ui/lib/Parser.js @@ -2,12 +2,18 @@ var Parser = { integrations: [{ type: 'image', regex: /\.(jpeg|jpg|gif|png|svg)(\?.*)?$/i, - async: false, fetch: function(url, done) { var img = new Image () img.onload = function(){ - done("", "", img.naturalWidth, img.naturalHeight, "") + var width = img.naturalWidth, height = img.naturalHeight img = null + done({ + token: "", + thumbnail: "", + title: "", + width: width, + height: height, + }) } img.src = url if (img.complete) { @@ -17,10 +23,31 @@ var Parser = { tag: function (media) { return ''; } + }, { + type: 'video', + regex: /\.(mp4|webm)(\?.*)?$/i, + fetch: function(url, done) { + var video = document.createElement("video") + video.addEventListener("loadedmetadata", function(){ + var width = video.videoWidth, height = video.videoHeight + video = null + done({ + token: "", + thumbnail: "", + title: "", + width: width, + height: height, + }) + }) + video.src = url + video.load() + }, + tag: function (media) { + return '