weixin_39917046 2020-11-30 16:03
浏览 0

Better Image Dimension Handling

Right now, things aren't ideal with the image dimension extractor. - Everything is done on render, which makes things slow. - The attachment metadata extractor is super slow on sites with lots of attachments. - We often end up having to fetch a remote image to calculate its dimensions, which is slow. - With lots of images on a post (e.g. gallery), we may end up taking a long time to generate the page. - fastimage has some flaws. - We do store the values in transients, but those expire after a while.

A few options to work with here: - Do the dimension calculations on upload and store them in meta. - For images without meta (uploaded when the plugin wasn't active): - Maybe a safe, async way to backfill image data. - Find a better/faster/more reliable library than fastimage (like https://github.com/willwashburn/fasterimage although this is PHP5.4+ only and we support 5.2+). - Use a 3rd party service to do the dimension extraction (something like Photon, although, that requires Jetpack support).

该提问来源于开源项目:ampproject/amp-wp

  • 写回答

5条回答 默认 最新

  • weixin_39917046 2020-11-30 16:03
    关注

    Use a 3rd party service to do the dimension extraction (something like Photon, although, that requires Jetpack support)

    For this (for Jetpack users only), it would be interesting to extend Photon return a JSON object containing width, height, aspect ratio, exif (if available), and any other data we can extract for the image at when queried with https://photonhost/example.com/image.jpg?metadata (for the image hosted at example.com/image.jpg).

    评论

报告相同问题?