2012-11-28 37 views
0

我試圖動態加載圖像:::有在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}' }"; 
     } 
    } 

本地化的所有屬性,我想發送到拉斯維加斯:::

// 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' }"]}; 
/* ]]> */ 
初始化輸出

我懷疑我的問題,有事情做與後臺斜線:::

回答

0

我不能讓我的執行工作:::但是我發現另一篇文章有​​一個合理的解決辦法,我繼續實施這個職位的選項,它的作品非常好Stackoverflow Post