首页 > 解决方案 > 如何更改 featherlight.js Wordpress 插件的默认值?

问题描述

当使用 featherlight 作为 wordpress 插件时,如何在不破坏主题等的情况下更改默认选项?

我看到我页面上加载的唯一 js 是 /wp-content/plugins/wp-featherlight/js/wpFeatherlight.pkgd.min.js?ver=1.3.0

目前我需要将所有这些属性添加到每个链接:

data-featherlight="iframe" 
data-featherlight-iframe-frameborder="0" 
data-featherlight-iframe-allow="autoplay; encrypted-media" 
data-featherlight-iframe-allowfullscreen="true" 
data-featherlight-iframe-style="position:fixed;background:#000;border:none;top:0;right:0;bottom:0;left:0;width:100%;height:100%;"

...这是很多重复的开销。如何将这些设置为所有 iframe 灯箱的默认值?

标签: wordpressfeatherlight.js

解决方案


您可以像这样全局设置默认值:

$.extend($.featherlight.defaults, {
  type: "iframe",
  iframeFrameborder: "0",
  iframeAllow: "autoplay; encrypted-media",
  iframeAllowfullscreen: "true",
  iframeStyle: "position:fixed;background:#000;border:none;top:0;right:0;bottom:0;left:0;width:100%;height:100%;",
});

推荐阅读