Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于图片加载相关问题 #2

Closed
mmdjiji opened this issue Aug 24, 2022 · 6 comments
Closed

关于图片加载相关问题 #2

mmdjiji opened this issue Aug 24, 2022 · 6 comments
Labels
compatibility Some styles are not compatible with some themes wontfix This will not be worked on

Comments

@mmdjiji
Copy link
Owner

mmdjiji commented Aug 24, 2022

原Issue:HCLonely/hexo-bilibili-bangumi#134

目前已知插件的懒加载和主题的懒加载存在冲突,如果同时启用就会导致点开一张图片一直转圈圈,就我个人建议的是关闭插件的懒加载,单独使用主题的全局懒加载,以此来给插件提供懒加载。(data-src 的问题已解决)

只需修改 _config.yml:

bangumis:
  lazyload: false

当然你也可以选择关闭主题的懒加载而单独使用插件的懒加载,但是这样可能并不优雅,尤其是涉及到全局统一性的时候,而且这样会增加不必要的耦合,除非主题没有懒加载功能。

@mmdjiji mmdjiji added wontfix This will not be worked on compatibility Some styles are not compatible with some themes labels Aug 24, 2022
@mmdjiji mmdjiji pinned this issue Aug 24, 2022
@mmdjiji
Copy link
Owner Author

mmdjiji commented Aug 24, 2022

在此展示部分代码,其中只需使 data-src 永远保持加载即可

<div class="bangumi-picture">
  <% if(download_image) { %>
  <img src="<%= lazyload ? ("/images/loading.gif") : `/images/${item.image}` %>" data-src="<%= `/images/${item.image}` %>" referrerPolicy="no-referrer" width="110" style="width:110px;margin:<%= margin %> auto;" />
  <% } else { %>
  <img src="<%= lazyload ? ("/images/loading.gif") : `https://lain.bgm.tv/pic/cover/c/${item.image}` %>" data-src="<%= `/images/${item.image}` %>" referrerPolicy="no-referrer" width="110" style="width:110px;margin:<%= margin %> auto;" />
  <% } %>
</div>

@mmdjiji mmdjiji closed this as completed Aug 24, 2022
@mmdjiji
Copy link
Owner Author

mmdjiji commented Dec 29, 2022

其实这个问题是主题对懒加载的不适配,我们可以在这里开启懒加载,但遇到不适配的主题就会出问题。在这里我提供一个主题适配懒加载的方案,只需要先让主题套 <a> 标签时检测 data-src 即可适配懒加载,为了不修改主题源码,我写了一段针对 Icarus 主题的适配代码,只需在 build 后执行即可。

let main_js = fs.readFileSync('public/js/main.js');
main_js = main_js.replace(
  `$(this).wrap('<a class="gallery-item" href="' + $(this).attr('src') + '"></a>');`,
  `$(this).wrap('<a class="gallery-item" href="' + $(this).attr('data-src') || $(this).attr('src') + '"></a>');`,
);
fs.writeFileSync('public/js/main.js', main_js);

@blhorizon
Copy link

翻页按钮不生效

@blhorizon
Copy link

VM6484:6 Uncaught TypeError: Cannot read properties of undefined (reading 'click')
at :6:54
at module.exports (pjax.min.js:1:7651)
at pjax.min.js:1:9113
at NodeList.forEach ()
at module.exports (pjax.min.js:1:9364)
at module.exports (pjax.min.js:1:8931)
at pjax.min.js:1:4649
at NodeList.forEach ()
at module.exports (pjax.min.js:1:9364)
at pjax.min.js:1:4589

@mmdjiji
Copy link
Owner Author

mmdjiji commented Jun 17, 2023

可否单独开一个issue,介绍一下你使用的主题和番组计划的uid,方便复现场景,或者有没有已经部署可访问的链接

@blhorizon
Copy link

可否单独开一个issue,介绍一下你使用的主题和番组计划的uid,方便复现场景,或者有没有已经部署可访问的链接

收到你的消息回去重新安装插件后,好了。我的链接:https://blhorizon.github.io/bangumis/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility Some styles are not compatible with some themes wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants