nathan-degraaf/wp-glide
Composer 安装命令:
composer require nathan-degraaf/wp-glide
包简介
A wrapper for PHP Glide through Composer
README 文档
README
A wrapper for PHP Glide/composer. Built for >= php@7.2 and >=php@8.0.
A build off of the no longer maintained Aginevs wp-glide wrapper.
Install
composer require nathan-degraaf/wp-glide
Usage
General configuration could be made at your function.php file in your theme, Though I recommend creating a dedicated glide file for your presets.
Create Instance
It's a singleton instance, so you will get just the same object everywhere in your application.
$wpGlide = wp_glide();
Server config
You should config WpGlide at least once in your application. The init method could have four parameters and all of them are not required.
$wpGlide = wp_glide()->init([ // Glide server config. See: http://glide.thephpleague.com/2.0/config/setup/ [ // Image driver 'driver' => 'imagick', // Watermarks path 'watermarks' => new \League\Flysystem\Filesystem(new \League\Flysystem\Adapter\Local(get_template_directory() . '/assets/img')), ], // Base path. By default set to 'img/' and the final URL will look like so: http://example.com/BASE-PATH/SIZE-SLUG/image.jpg. 'img/', // Path to WordPress upload directory. If not set the default upload directory will be used. 'upload_path', // Cache path. If not set the cache will be placed in cache directory at the root of the default upload path. 'cache_path' ]);
Register image sizes
You should register image sizes that will be handled by Glide like so:
$wpGlide->addSize('size_name', [ 'w' => 1400, 'q' => 80, 'fm' => 'webp', 'mark' => 'watermark.png', 'markw' => 1000, 'markh' => 1000, 'markalpha' => 55, 'markfit' => 'fill', 'markpos' => 'center', ])->addSize('size_name_512', [ 'w' => 512, 'q' => 80, 'fm' => 'webp', ])->addSize('16x9', [ 'w' => 16 * 10 * 2, 'h' => 9 * 10 * 2, 'fit' => 'crop', 'q' => 80, 'fm' => 'webp', ]);
Usage in templates
<!-- Get Glide image URL by it's original URL --> <img src="<?php echo wp_glide_image('https://yourimage.com', 'size_name'); ?>" />
retrive base64 encoded version:
<!-- Get Glide image URL by it's original URL --> <img src="<?php echo wp_glide_base64('http://example.com/image.jpg', 'w128'); ?>" />
License
Everything in this repository is MIT License unless specified.
MIT © 2022 Nathan deGraaf
nathan-degraaf/wp-glide 适用场景与选型建议
nathan-degraaf/wp-glide 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.46k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 11 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「composer」 「wordpress」 「php-glide-for-wordpress」 「php-8」 「nathan」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 nathan-degraaf/wp-glide 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nathan-degraaf/wp-glide 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 nathan-degraaf/wp-glide 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
This composer plugin enables installation of GravityForms WordPress plugin and its addons.
Simple ASCII output of array data
Alfabank REST API integration
Generate a Composer repository from installed WordPress plugins and themes.
An image upload package which provides lot of functions such as upload, resize, crop, rotate, delete.
统计信息
- 总下载量: 2.46k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-22