I have downloaded WordPress theme and I want to modify it for my needs. So my problem is: There is slideshow in the theme and it's loading the images that are showing one after another. I posted the code below, but the part that we are interested in, is the part where we assign the locations to the images. Let's say that I have only one image: If I have that image somewhere on my server I can load it in the slideshow if I add the path of the location on the server http://myServer/path/to/the/image.jpg
, for that image. I tried that and it's working. The problem is that the image I want to load is on the other external URL, so when I replace that line with http://myOtherServer/path/to/the/image.jpg
the image is not showing.
The error that I got at console is:
Uncaught Error: Syntax error, unrecognized expression: http://myOtherServer/path/to/the/image.jpg
This is the jQuery code in my .php script:
$j(document).ready(function(){
$j('#kenburns_overlay').css('width', $j(window).width() + 'px');
$j('#kenburns_overlay').css('height', $j(window).height() + 'px');
$j('#kenburns').attr('width', $j(window).width());
$j('#kenburns').attr('height', $j(window).height());
$j(window).resize(function() {
$j('#kenburns').remove();
$j('#kenburns_overlay').remove();
$j('body').append('<canvas id="kenburns"></canvas>');
$j('body').append('<div id="kenburns_overlay"></div>');
$j('#kenburns_overlay').css('width', $j(window).width() + 'px');
$j('#kenburns_overlay').css('height', $j(window).height() + 'px');
$j('#kenburns').attr('width', $j(window).width());
$j('#kenburns').attr('height', $j(window).height());
$j('#kenburns').kenburns({
images: "http://myServer/path/to/the/image.jpg",
frames_per_second: 30,
display_time: 5000,
fade_time: 1000,
zoom: 1.2,
background_color:'#000000'
});
});
$j('#kenburns').kenburns({
images: "http://myServer/path/to/the/image.jpg",
frames_per_second: 30,
display_time: 5000,
fade_time: 1000,
zoom: 1.2,
background_color:'#000000'
});
});
I also tried adding:
var imgS = new Image();
imgS.src = 'http://myOtherServer/path/to/the/image.jpg';
and then replace the path with:
images: imgS,
and it's giving me the error:
Resource interpreted as Image but transferred with MIME type text/html: "<currentUrl>/object%20HTMLImageElement/".
btw. on the top of my .php script I have:
header("content-type: application/x-javascript");
So the general questin is: How can I get the images that are stored on another server within my jQuery code?
EDIT 1:
This is the part inside kenburns
where probably the images are requested:
$.fn.kenburns = function(options) {
...
var image_paths = options.images;
var images = [];
$(image_paths).each(function(i, image_path){
images.push({path:image_path,
initialized:false,
loaded:false});
});
...
}
EDIT 2:
I also tried to create <img src="http://myOtherServer/path/to/the/image.jpg"/>
tag and I passed that as on object but again I got the error:
Resource interpreted as Image but transferred with MIME type text/html: "<currentUrl>/object%20HTMLImageElement/".