mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-16 05:10:00 +01:00
fixed replaceImage (#151)
* 1.0.0 * Fixed Replace Image * Added test to check if replaceImage works
This commit is contained in:
committed by
Jeffrey Warren
parent
73e5d14569
commit
3f99e2b44c
@@ -1,13 +1,15 @@
|
||||
function ReplaceImage(ref,selector,steps,options) {
|
||||
if(!ref.options.inBrowser) return false; // This isn't for Node.js
|
||||
var tempSequencer = ImageSequencer({ui: false});
|
||||
var this_ = ref;
|
||||
var input = document.querySelectorAll(selector);
|
||||
var images = [];
|
||||
for (var i = 0; i < input.length; i++)
|
||||
for (var i = 0; i < input.length; i++) {
|
||||
if (input[i] instanceof HTMLImageElement) images.push(input[i]);
|
||||
for (var i in images) {
|
||||
var the_image = images[i];
|
||||
var url = images[i].src;
|
||||
}
|
||||
|
||||
function replaceImage (img, steps) {
|
||||
var url = img.src;
|
||||
var ext = url.split('.').pop();
|
||||
|
||||
var xmlHTTP = new XMLHttpRequest();
|
||||
@@ -25,11 +27,19 @@ function ReplaceImage(ref,selector,steps,options) {
|
||||
else make(url);
|
||||
|
||||
function make(url) {
|
||||
this_.loadImage('default',url).addSteps('default',steps).run(function(out){
|
||||
the_image.src = out;
|
||||
tempSequencer.loadImage(url, function(){
|
||||
this.addSteps(steps).run(function(out){
|
||||
img.src = out;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < images.length; i++) {
|
||||
replaceImage(images[i],steps);
|
||||
if (i == images.length-1)
|
||||
options.callback();
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ReplaceImage;
|
||||
|
||||
Reference in New Issue
Block a user