Git Product home page Git Product logo

Comments (2)

zgq354 avatar zgq354 commented on August 30, 2024

一个比较*的思路:
监听帖子的 img onload 事件,然后再重新触发楼层跳转

from flarum-0x.

zgq354 avatar zgq354 commented on August 30, 2024

改好了,这里没有采用上述的办法:
而是借助 image 的 width / height 属性,指定完整的 width / height 来固定住 img 的 aspect ratio,避免 loading 过程中发生偏移。

思路:

  1. 在 formatter render 之前,补充 width / height 属性
  2. 利用 cache 和 queue 异步获取帖子图片的 width / height

细节:

  1. 安全考虑:增加一个 fetchImageSizeAllowList 的白名单,只有指定域名才走这里的优化策略
  2. 指定了 width / height 后,max-width: 100% 情况会变形,这里为 img 补充 height: auto 样式来补偿

from flarum-0x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.