I am having a really hard time understanding this. I am selecting all image tags based on whether they have the word /resize/ in the src of the img tag (I think its returning an array...?). Then I want to check each src to see if there is a file where specified in the src location of that img tag. If the image does exist, then I want to pull out that image from the array, but it won't remove. It's also saying Uncaught TypeError: images.indexOf is not a function.
Here is my code -
var images = [];
var images = $(' img[src*="/resize/"]');
console.log(images);
$.each(images, function(key, value){
var getFile = $(value).data('src');
$.ajax({
type: 'HEAD',
url: getFile,
success: function() {
var index = images.indexOf(key);
if (index > -1) {
images.splice(index, 1);
}
},
error: function() {
}
});
x++;
});
Can someone please help? This is killing me...
images? It doesn't haveindexOfmethod./files/. What I'm wanting to do is check if it doesn't exist in/resize/files/, if it doesn't then make a refactored array with all the images that have/resize/in the src and don't yet exist in that directory, grab the oringinal image files from/files/and run an ajax crop script, and make it exist in/resize/files.