I'm using cordova-plugin-wallpaper which works fine if i hardcode image like this.
window.plugins.wallpaper.setImage("images/1462204239933.jpg");
but if i try to get image link with jquery from active slide, it won't set wallpaper with android app. This is what i tried.
var picture = $$(".swiper-slide-active").find(".pic").attr('src');
window.plugins.wallpaper.setImage('"'+picture+'"');
I checked console.log and it's getting image src fine for each slide. Any suggestion how to work around this? Thanks
There was strings around variable ('"'+picture+'"')
which were causing the issue. Removing that fixed the issue. Thanks to "flyingP0tat0" for pointing this on github issue.
Here is the full code if anyone need.
HTML
<div class="page-content">
<button class="setwp floating-button"><i class="icon icon-plus"></i></button>
<div class="swiper-container">
<div class="swiper-wrapper">
<div class="swiper-slide"><img src="images/001.jpg" rel="1"></div>
<div class="swiper-slide"><img src="images/002.jpg" rel="2"></div>
<div class="swiper-slide"><img src="images/003.jpg" rel="3"></div>
</div>
</div>
</div>
JS
function wp() {
var wppic = $$(".swiper-slide-active").find("img").attr('src');
window.plugins.wallpaper.setImage(wppic);
}
function wpalert() {
alert('Wallpaper is set');
}
$$('.setwp').on('click', function (e) {
wp(); wpalert();
});
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.