定制 humanmade/tachyon-plugin 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

humanmade/tachyon-plugin

Composer 安装命令:

composer require humanmade/tachyon-plugin

包简介

Rewrites WordPress image URLs to use Tachyon

README 文档

README

Tachyon
Faster than light image processing. Inspired / forked from Photon.
Build status Coverage via codecov.io
A Human Made project. Maintained by @joehoyle.

Tachyon is an image resizing service built to be used with Amazon S3 as the image backend, AWS Lambda (or any node.js server) to process images using sharp, and sits behind a CDN such as CloudFront or CloudFlare.

This plugin handles modifying WordPress image URLs to use a Tachyon service instance.

Installation

  1. Upload and enable this plugin.
  2. Add define( 'TACHYON_URL', 'https://your.tachyon.url/path/to/uploads' ) to your wp-config.php file.

Usage

Typically the above steps are all you need to do however you can use the following public facing functions and filters.

Functions

tachyon_url( string $image_url, array $args = [] )

This function returns the Tachyon URL for a given image hosted on Amazon S3.

$image_url = 'https://my-bucket.s3.us-east-1.amazonaws.com/path/to/image.jpg';
$args      = [
	'resize'  => '300,300',
	'quality' => 90
];

$url = tachyon_url( $image_url, $args );

Filters

The following filters allow you to modify the output and behaviour of the plugin.

tachyon_disable_in_admin

Defaults to true. You can override this by adding the following code to a plugin or your theme's functions.php:

add_filter( 'tachyon_disable_in_admin', '__return_false' );

tachyon_override_image_downsize

Defaults to false. Provides a way of preventing Tachyon from being applied to images retrieved from WordPress Core at the lowest level, you might use this if you wanted to use tachyon_url() manually in specific cases.

add_filter( 'tachyon_override_image_downsize', '__return_true' );

tachyon_skip_for_url

Allows skipping the Tachyon URL for a given image URL. Defaults to false.

add_filter( 'tachyon_skip_for_url', function ( $skip, $image_url, $args ) {
	if ( strpos( $image_url, 'original' ) !== false ) {
		return true;
	}
	
	return $skip;
}, 10, 3 );

tachyon_pre_image_url

Filters the Tachyon image URL excluding the query string arguments. You might use this to shard Tachyon requests across multiple instances of the service for example.

add_filter( 'tachyon_pre_image_url', function ( $image_url, $args ) {
	if ( rand( 1, 2 ) === 2 ) {
		$image_url = str_replace( TACHYON_URL, TACHYON_URL_2, $image_url );
	}
	
	return $image_url;
}, 10, 2 );

tachyon_pre_args

Filters the query string parameters appended to the tachyon image URL.

add_filter( 'tachyon_pre_args', function ( $args ) {
	if ( isset( $args['resize'] ) ) {
		$args['crop_strategy'] = 'smart';
	}
	
	return $args;
} );

tachyon_remove_size_attributes

Defaults to true. width & height attributes on image tags are removed by default to prevent aspect ratio distortion that can happen in some unusual cases where srcset sizes have different aspect ratios.

add_filter( 'tachyon_remove_size_attributes', '__return_true' );

Credits

Created by Human Made for high volume and large-scale sites, such as Happytables. We run Tachyon on sites with millions of monthly page views, and thousands of sites.

Written and maintained by Joe Hoyle.

Tachyon is forked from Photon by Automattic Inc. As Tachyon is not an all-purpose image resizer, rather it uses a media library in Amazon S3, it has a different use case to Photon.

Interested in joining in on the fun? Join us, and become human!

humanmade/tachyon-plugin 适用场景与选型建议

humanmade/tachyon-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 358.07k 次下载、GitHub Stars 达 87, 最近一次更新时间为 2018 年 09 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 humanmade/tachyon-plugin 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 humanmade/tachyon-plugin 我们能提供哪些服务?
定制开发 / 二次开发

基于 humanmade/tachyon-plugin 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 358.07k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 87
  • 点击次数: 20
  • 依赖项目数: 2
  • 推荐数: 0

GitHub 信息

  • Stars: 87
  • Watchers: 17
  • Forks: 16
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2018-09-19