Reputation: 27
Is there a way to make the below script apply to just iframe in fancybox? I have a page with both gallery and iframe. I want the iframe to have different heights without affecting the image sizes.
$('.fancybox').fancybox({
afterLoad: function () {
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
}
});
Upvotes: 1
Views: 989
Reputation: 1164
this code work for me!
$.fancybox.open({
maxWidth: 1263,
// fitToView: true,
width: '90%',
// maxHeight: 292,
autoSize: false,
closeClick: false,
openEffect: 'elastic',
closeBtn: true,
closeEffect: 'elastic',
href: '/team/' + $(this).data("cv") + '_team.html',
type: 'iframe',
'afterShow': function() {
$(".fancybox-wrap").height($(".fancybox-iframe").contents().find("html").height() + 30);
$(".fancybox-skin").height($(".fancybox-iframe").contents().find("html").height());
$(".fancybox-inner").height($(".fancybox-iframe").contents().find("html").height());
}
});
Upvotes: 1
Reputation: 41143
You can set a condition to validate the type
of content before passing the data-*
values to fancybox like :
$(".fancybox").fancybox({
afterLoad: function () {
if (this.type == "iframe") {
this.width = $(this.element).data("width");
this.height = $(this.element).data("height");
};
}
});
You could also refer to $(this)
like this.element
$(".fancybox").fancybox({
afterLoad: function () {
if (this.type == "iframe") {
this.width = this.element.data("width");
this.height = this.element.data("height");
};
}
});
Upvotes: 1