Answers for "js get image from url"

2

js get image src

var youtubeimgsrc = document.getElementById("youtubeimg").src;
Posted by: Guest on September-17-2020
1

js get image from url

var elements = [];
function loaded(){
  console.log("you have loaded an image");
}
CreateFileFrom("your/dir/here/img.png");

function CreateFileFrom(dir){

  		/* defining runtime variables */
	  		var extension                        =   dir.split('.').pop();
	  		var keys                             =   {"png":"IMG","jpg":"IMG","jpeg":"IMG",
	  												  "js":"SCRIPT","json":"SCRIPT",
	  												  "mp3":"AUDIO","wav":"AUDIO"};
	  	    var obj                              =   document.createElement(keys[extension]) || {};
	  	    obj.src                              =   dir;
	  	    
	  	/* onload function called when the resource is loaded */
	  	    obj.onload                           =   (e) => {

	  	    	elements.push(e.path[0]);
	  	    	loaded()
	  		}

  		/* make sure that the data is compitable */
  			if(keys[extension]==null){console.error("not supported media type "+extension);return;}
  	}
Posted by: Guest on April-11-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language