简体   繁体   中英

jquery if statement help with supersized plugin

I need help with the following piece of code, I would like to see if the current image is set, if not display default image instead.

This is my code:

jQuery(function($){
            $.supersized({
                slides  :   [ {image : '<?php echo get_post_meta($post->ID, 'upload_image', true); ?>' } ]
            });
        });

Try this

jQuery(function(){
       var settings = {
                slides  :   [ {image : '<?php echo get_post_meta($post->ID, 'upload_image', true); ?>' } ]
            };

       if(!settings.slides[0].image)
          settings.slides[0].image = "setTheDefaultImageHere";

            $.supersized(settings);
        });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM