[RESOLVED] : Adding background image or full bleed images
#227
Is there a way of making the images full bleed, despite the actual image dimensions.
Currently the images are scaled down to fit the parent, but I am trying to get the image to be full bleed, something like "background-size:cover"
Thanks
#1357 Found a solution.
Doing this will make the container 100% : http://jsfiddle.net/RyTcS/embedded/result/
But: .fancybox-placeholder will be set to display none and image will be it's normal size.
Add this extra css to make it full bleed.
.fancybox-placeholder {
display: block !important;
position: relative;
height: 100%;
}
.fancybox-placeholder img {
object-fit: cover;
}
** object-fit:cover is the answer, this makes the images behave the same way as background-size:cover ** See usage and compatibility: http://caniuse.com/#search=object-fit
You can trick the script to show images as html content:
$(document).on('beforeLoad.fb', function( e, instance, current ) {
current.type = 'html';
current.content = '<div class="fancybox-image" style="background-image:url(' + current.src + '); background-size: cover; background-position:50% 50%;background-repeat:no-repeat;height:100%;width:100%;" /></div>';
});
See demo - http://codepen.io/fancyapps/pen/NjKxpQ
Maybe some day this will be included in the core.
Duplicate of #227
It would be really nice to have it in 3.1 - blurred images are not cool