Closed cengizilhan closed 3 years ago
Ah, so zoom doesn't know to look at background-images. My suggestion would be to do something like this where you explicitly tell zoom what the image should be:
<div id='ex1' style='width: 555px; height: 320px; background: url("daisy.jpg") center center / contain no-repeat;'></div>
<script>
$(document).ready(function(){
$('#ex1').zoom({ url: 'daisy.jpg' });
});
</script>
Or something like this where you get the computed background-image style off a specific DOM element:
<div id='ex2' style='width: 555px; height: 320px; background: url("daisy.jpg") center center / contain no-repeat;'></div>
<script>
$(document).ready(function(){
$('#ex2').each(function(){
$(this).zoom({ url: $(this).css('background-image').slice(5,-2) });
});
});
</script>
The value of $(this).css('background-image')
in this case will be url("daisy.jpg")
, so adding .slice(5,-2)
is for trimming off the url("")
that wraps the image path that we want. Hope that all makes sense.
Hey guys, (it is not issue) im not using im using as <div style="background-image" and thats not working on my project.. how can i do it?