Refer fiddle
$(".fancybox")
.attr('rel', 'gallery')
.fancybox({
padding : 0,
margin : 5,
nextEffect : 'fade',
prevEffect : 'none',
afterLoad : function () {
$.extend(this, {
aspectRatio : false,
type : 'html',
width : '70%', // pop up image width - set as required
height : '70%', // pop up image height- set as required
content : '<div class="fancybox-image" style="background-image:url(' + this.href + '); background-size: cover; background-position:50% 50%;background-repeat:no-repeat;height:100%;width:100%;" /></div>'
});
}
});