I have a javascript i want to compress a little
The basic idea is it looks for files from a json file If the file is MP4,mkv,avi, < any video format. It appends the url in a tag
if its an image it does the same With an tag.
here is my code.
//example
var link = "video.mp4";
var videoorimg = link.split(".").pop(1);
if(videoorimg === "mp4"){
$("body").append('<video src="'+ link +'">');
}
if(videoorimg === "jpg"){
$("body").append('<img src="'+ link +'">');
}
this is fine. How ever im running into issues where there is multiple file types for images and video.
My idea was an array like this.
//example
function imgarry(){
jpg,
png,
jpeg,
bmp,
tiff,
}
function videoarry(){
mkv,
mp4,
mov,
avi,
m4v,
}
var link = "video.mp4";
var videoorimg = link.split(".").pop(1);
if(videoorimg === videoarry() ){
$("body").append('<video src="'+ link +'">');
}
if(videoorimg === imgarry() ){
$("body").append('<img src="'+ link +'">');
}
how ever i know this is incorrect, Is there a way i can achieve this though?
Aucun commentaire:
Enregistrer un commentaire