10 examples of 'jquery image src' in JavaScript

Every line of 'jquery image src' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
78function getImageSrc(src) {
79 return window.isLocal ? '/demo/' + src : src;
80}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

122function setImage(el, src) {
123
124 var image = new Image();
125
126 image.onload = function() {
127 el.setAttribute('src', src);
128 };
129
130 image.src = src;
131}
868function loadImage(src, callback) {
869 var img = new Image();
870 img.onload = function () {
871 callback.apply(this, arguments);
872 };
873 img.src = src;
874 return img;
875}
54function loadImg(src, callback) {
55 var img = new Image();
56 img.src = src;
57 img.onload = function(event) {
58 loadImg.loaded++;
59 callback && callback(event);
60 };
61 return img;
62}
79function preloadImg(image) {
80 var img = new Image();
81 img.src = image;
82}
125export function preloadImage(url, onload) {
126 const image = new Image();
127 image.src = url;
128 image.onload = onload;
129 return image;
130}
165function isImageLoaded($img){
166 return $img.get(0).complete;
167};
67function setImage(element, url) {
68 var property = "url(" + url + ")";
69 element.style.backgroundImage = property;
70}
119private loadImage(src:string):void {
120 var image = new Image();
121 this.data = null;
122 this.currentImage = image;
123 if (this.crossOrigin) {
124 image.crossOrigin = this.crossOrigin;
125 }
126 image.onload = this.onImageComplete;
127 image.onerror = this.onLoadError;
128 image.src = src;
129}
1275function imageLoaded(image, callback) {
1276
1277 if (!image.nodeName || image.nodeName.toLowerCase() !== 'img')
1278 return callback(new Error('First argument must an image element'));
1279
1280 if (image.src && image.complete && image.naturalWidth !== undefined)
1281 return callback(null, true);
1282
1283 image.addEventListener('load', function() {
1284 callback(null, false);
1285 }.bind(this));
1286
1287 image.addEventListener('error', function(e) {
1288 callback(new Error('Failed to load image \'' + (image.src || '') + '\''));
1289 }.bind(this));
1290
1291 if (image.complete) {
1292 src = image.src;
1293 image.src = BLANK;
1294 image.src = src;
1295 }
1296}

Related snippets