Every line of 'check if string is file image javascript' 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.
91 function isImageFile(file) { 92 for (var i in ImageFileExtentsions) { 93 var key = ImageFileExtentsions[i] 94 if (file.toLowerCase().endsWith('.' + key)) { 95 return true; 96 } 97 } 98 return false; 99 }
26 export function isImage(file: File) { 27 if (!(file instanceof window.File)) return false; 28 const type = `|${file.type.slice(file.type.lastIndexOf('/') + 1)}|`; 29 return '|jpg|png|jpeg|bmp|gif|'.indexOf(type) !== -1; 30 }
58 function isImageFile(path) { 59 return /\.(jpe?g|gif|png)$/.test(path); 60 }
33 static getIsImageFile(fileExtension: string): boolean { 34 return ['jpg', 'jpeg', 'png', 'webp', 'gif'].indexOf(fileExtension) > -1; 35 }
4 export function isImage(image) { 5 return Boolean(getImageTypeOrNull(image)); 6 }
17 export function isImageFile(item: File): boolean { 18 if (item.type) { 19 return item.type.indexOf('image') === 0; 20 } 21 22 if (item.path) { 23 return isImageUrl(item.path); 24 } 25 26 if (item.url) { 27 return isImageUrl(item.url); 28 } 29 30 return false; 31 }
69 function isValidImage (filename) { 70 return (/\.(gif|jpg|jpeg|png)$/i).test(filename) 71 }
89 function isImg(relativePath) { 90 return checkSuffix(relativePath, imgSuffixs); 91 }
344 function validateImageUrl(imagePath) { 345 var filePath = /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i; 346 if(!filePath.exec(imagePath)) return false; 347 348 var fileExt = /(\.jpg|\.jpeg|\.gif|\.png)$/i; 349 if(!fileExt.exec(imagePath)) return false; 350 351 return true; 352 }
71 export function isImageAsset(asset, locale) { 72 return ( 73 asset.fields.file[locale] && 74 /^image\//.test(asset.fields.file[locale].contentType) 75 ) 76 }