import fetch from 'node-fetch' import fetchJsonp from 'fetch-jsonp' export const integrations = [ { type: 'image', regex: /\.(jpeg|jpg|gif|png|svg)(\?.*)?$/i, fetch: function(url, done) { var img = new Image () img.onload = function(){ if (!img) return var width = img.naturalWidth, height = img.naturalHeight img = null done({ url: url, type: "image", token: "", thumbnail: "", title: "", width: width, height: height, }) } img.src = url if (img.complete) { img.onload() } }, tag: function (media) { return ''; } }, { type: 'video', regex: /\.(mp4|webm)(\?.*)?$/i, fetch: function(url, done) { var video = document.createElement("video") var url_parts = url.replace(/\?.*$/, "").split("/") var filename = url_parts[ url_parts.length-1 ] video.addEventListener("loadedmetadata", function(){ var width = video.videoWidth, height = video.videoHeight video = null done({ url: url, type: "video", token: url, thumbnail: "/public/assets/img/video-thumbnail.png", title: filename, width: width, height: height, }) }) video.src = url video.load() }, tag: function (media) { return '