我正在尝试动态加载图片:::在WordPress :::
中包含以下代码这就是我计划获取图像数据的原因:::
//For Demo I'm simulating some data
$url = 'http://localhost/lolo-wp/wp-content/uploads/2012/10/image_02.jpg,http://localhost/mocha/wp-content/uploads/2012/11/image_02.jpg';
$urls = explode(',', $url);
if( is_array($urls) ) {
// $vega_bg ='';
foreach( $urls as $url ) {
$vega_bg[] = "{ src:'{$url}' }";
}
}
将我想发送给Vegas :::
的所有属性本地化// Localization
wp_localize_script( 'vegas_init', 'vegassettings', array(
'delay' => 5000,
'fade' => 1000,
'backgrounds' => $vega_bg
));
我的拉斯维加斯初始化:::
vega_delay = parseInt(vegassettings.delay);
vega_fade = parseInt(vegassettings.fade);
vega_bg = vegassettings.backgrounds;
vega_att = {
fade:vega_fade,
delay:vega_delay,
backgrounds:[ vega_bg ]
};
jQuery(document).ready(function($){
jQuery.vegas('slideshow',
vega_att
)
('overlay');
function preloadImg(imgPath) {
preloadImg = new Image();
preloadImg.src = imgPath;
}
}); //Doc load
这不起作用:::但是如果我发出警报(vega_bg),我会得到以下 vega_bg = {src:'http:// localhost / mocha / wp-content / uploads / 2012/11 / image_01。 jpg'},{src:'http://localhost/lolo-wp/wp-content/uploads/2012/10/image_02.jpg'},
如果我用上面复制的字符串替换vega_att
一切正常:::任何帮助都将被赞赏:::
这就是我的HTML :::
中的初始化输出/* <![CDATA[ */
var vegassettings = {"delay":"5000","fade":"1000","backgrounds":["{ src:'http:\/\/localhost\/lolo-wp\/wp-content\/uploads\/2012\/10\/slider-02.jpg' }","{ src:'http:\/\/localhost\/mocha\/wp-content\/uploads\/2012\/11\/hdr-076.jpg' }"]};
/* ]]> */
我怀疑我的问题与反斜杠有关:::