How to set autoSize and autoWidth in fancybox 3?
Hello
We have set below code in old fancybox, But i need to use in fancybox 3, So how can use/ set autoSize and autoWidth in fancybox 3.
Please give me advice
autoSize: false,
autoWidth : false,
Thank you, PressLayouts.
Hi,
Older versions of fancyBox used JS to size and position html content. In v3 it is done using CSS and therefore there is no need for these options.
You control content dimensions using CSS only - you can now use any CSS values you need, for example, vw/vh units, calc(), etc.
We are sorry, we don't understand you.
At this time display popup in full width but i need to display specific width, So how can manage it, Please give me one example.
Thank you for fast reply.
What content type are you using? Ajax, inline,..?
Ajax type
See below code HTML and js:
HTML Code:
<a class="quickview" href="#" data-product_id="187">Quick View</a>
JS Code:
$(document).on('click', '.quickview', function(e) {
e.preventDefault();
var pid = $(this).attr('data-product_id');
$.fancybox.open({
src : myAjax.ajaxurl + '?action=fan_product_quickview&pid=' + pid,
type : 'ajax',
opts : {
onComplete : function() {
$('.flex-control-thumbs').owlCarousel({
loop: true,
responsiveClass: true,
responsiveRefreshRate : 10,
rtl : fan_rtl,
nav: true,
navText: ['',''],
dots:false,
items: 3,
});
}
}
});
return false;
});
Thank you.
Take a look at example from documentation - http://codepen.io/fancyapps/pen/JEoOvK?editors=1100 In this example, ajax response is something like this:
<div class="modal-container">
<div class="modal-title">Modal title</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">..</div>
</div>
This HTML code is inserted into page and, obviously, you can style it however you want, for example:
.modal-container {
max-width: 500px;
padding: 0;
margin: 0;
border-radius: .3em;
box-shadow: 0 0.1em 0.4em rgba(0,0,0,.3);
}
Hello fancyapps,
When i added modal-container div, then added extra div automatically, So popup look not good. How can remove this div and resolve our issue. Please see below link and give me hint.
http://prnt.sc/f0wyrn http://prntscr.com/f0wz6t
Thank you in advance !!!
Make sure you have no white-space around your content.
Ooohhhh really good and fast support, Thank you so much.
Resolved my issue.
Thank you again, PressLayouts.
Hi, coming from Fancybox v2 we have a similar question but couldn't find a solution to it. We used autoResize : false and would need the exact same option for v3. The images shall not be enlarged. At least not on the desktop. Scaling them down if they are larger than the viewport would be fine. We experimented with CSS
.fancybox-image {
max-width:50%; max-height:auto;
}
but this does not work, since: the image is twice the size (shall be displayed at 50% for retina screens) and width/height is not defined in the image tag.
But what do you mean by " images shall not be enlarged " and " Scaling them down if they are larger than the viewport would be fine ". It is not clear if you want to disable zooming on click or what.
what if you have a two youtube videos and they are both different sizes but you want the lightbox to match the width and height of the video, i saw the example for sizing it with css but how could you add a custom class to the lightbox window that is output when the link is clicked? if i could apply a class per size, then i could write css to match the different sizes. OR if i could just autosize based on the content of the video, that would be best.
You could create links like this:
<a data-fancybox data-slide-class='customVid' href="https://www.youtube.com/watch?v=8iU8LPEa4o0">
YouTube
</a>
and then create CSS class:
.customVid .fancybox-content {
width: 530px;
height: 298px;
max-width: none;
max-height: none;
}
Demo - https://codepen.io/anon/pen/ooWobY?editors=1100
I'm using fancybox on this page: https://www.mystardr.com/before-after/ear-surgery/
When you click on the image, it then renders it using width I don't want. I know how to set max width, but I want the width to always be greater so it's not screwed up like this. Thanks!
@rabbijason Hi, You are using the first version of fancyBox, it is 8 years old and is no longer supported.
Hi @fancyapps
I'm not starting new topic since my question is related. I have a .mp4 video and FB3 is opening it nicely. Now only problem for me is a black area around the video. Setting size with CSS for fancybox-content work for me but i can't seem to add slideClass to iframe content. The class name don't get added. Maybe you have any better suggestion ?
My html is like that:
<a data-fancybox href="http://techslides.com/demos/sample-videos/small.mp4">Click here and watch the video</a>
@kristjankoppel Just wait for v3.3 where support for aspect ratio will be implemented - https://codepen.io/fancyapps/pen/gopGNq (along with possibility to link directly to video files).
@fancyapps Ahhh that's a delight. I'll wait for this release for sure! What time approximately the release for 3.3 is planned?
Hi @fancyapps, I can't figure out how to set a max width for my image popup. At the moment it's the full width of the screen. I understand this is not an option anymore in the js and I've tried doing it with css but with no success. Thanks
v3.3 has been released and @jeffceriello - there is an example in the docs that show how to custoimize image dimensions.
@fancyapps - Can you clarify where I can find the use of custom image dimensions in the docs? I have just upgraded our site to use 3.3.5 to fix the aspect ratio issues we have with our images but I cannot find the documentation on how to do this for this version - thank you!