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");
};
}
});