该插件尚未通过WordPress的最新3个主要版本进行测试。 当与较新版本的WordPress一起使用时,可能不再受到维护或支持,并且可能会存在兼容性问题。

Squidge

描述

Squidge is a FREE WordpPress Plugin built for developers in mind compressing and convert images using jpegoptim,
optipng, cwebp, and libavif. It’s extremley simple to use and is designed to increase PSI and boost rankings.

Why?

Image compression in WordPress can be costly, confusing and sometimes just simply don’t work. We have aimed to simplify
the process by requiring the developer to install the required package on the operating system and Squidge does the
hard work for you.

  • IT’S FREE
  • Unlimited file size, no limits.
  • Optimised for your site to rank.
  • CLI to regenerate all of your media files.
  • Helper functions to output images in templates.
  • Uses the native cwebp and libavif libraries.

What does Squidge do?

Squidge compresses and converts image files when the user has uploaded a file to WordPress.

  • Compresses JPG images using jpegoptim.
  • Compresses PNG images using optipng.
  • Converts JPG and PNG images to .webp files using cwebp with the appended extension e.g. image.jpg.webp.
  • Converts JPG and PNG images to .avif files using libavif with the appended extension e.g. image.jpg.avif.

Render Images

To render images in templates, you can either set up nginx or apache rules to serve images dynamically or used the
squidge_image helper function. This dynamically checks if an .avif or .webp file is available on the file system
and returns the output.

Function

/**
 * Returns a <picture> element with source media for the standard file passed
 * (such as a JPG), the .avif file, the .webp file (if to exist on the file system).
 *
 * Appropriate <source> elements for image sizes with max widths.
 * Finally, the main be outputted with alt and title text.
 *
 * - If lazy is true, the data-src or data-srcset will be appended.
 * - If a class is set, the class will be outputted on the <picture> element.
 *
 * @param $image_id
 * @param string $class
 * @param false $lazy
 * @return string
 */
function squidge_image($image_id, $class = '', $lazy = false)

Output

<picture class="picture">
    <!-- Loads if AVIF is supported and the window is smaller than 400px wide -->
    <source media="(max-width: 400px)" srcset="/sample-image.jpg.avif" type="image/avif">
    <source media="(max-width: 400px)" srcset="/sample-image.jpg.webp" type="image/webp">
    <source media="(max-width: 400px)" srcset="/sample-image.jpg">
    <!-- AVIF & Wep Initial Sizes -->
    <source srcset="/sample-image.jpg.avif" type="image/avif">
    <source srcset="/sample-image.jpg.webp" type="image/webp">
    <!-- Default -->
    <img src="/sample-image.jpg" alt="Alt text" title="Sample JPG">
</picture>

Credits

Written by Ainsley Clark

屏幕截图

  • Plugin settings page
  • Example compression tab

安装

  1. Go to the releases section and download the plugin.
  2. Upload the squidge plugin to your /wp-content/plugins/ directory.
  3. Activate the plugin through the “Plugins” menu in WordPress.
  4. Check the Settings tab under Settings | Squidge Options to ensure the libraries are installed, if they aren’t,
    run the commands listed dependent on your operating system.
  5. Check the individual optimisation tabs and adjust settings accordingly.
  6. Done!

常见问题

Does the plugin replace existing images?

Yes

What are the supported operating systems?

Windows, Linux, & Mac OSX.

评价

2023 年 2 月 13 日
Doesn't work at all. Tried it on two different websites. On both websites the settings pages is empty. No setting adjustments possible.
2021 年 12 月 30 日
This looks promising! It seems to be the only such solution for avif that can run on the user's own hosting.
2021 年 12 月 21 日
I'll be using this plugin for all my projects for sure! It's really useful as compression can be a nightmare with WordPress. Can't believe it's free too.
阅读所有3条评价

贡献者及开发者

“Squidge” 是开源软件。 以下人员对此插件做出了贡献。

贡献者

「Squidge」插件已被翻译至 1 种本地化语言。 感谢所有译者为本插件所做的贡献。

将“Squidge”翻译成您的语言。

对开发感兴趣吗?

您可以浏览代码,查看SVN仓库,或通过RSS订阅开发日志

更新日志

0.1.0

  • Initial Release