rapidez/image-resizer
Composer 安装命令:
composer require rapidez/image-resizer
包简介
Rapidez Image Resizer
关键字:
README 文档
README
Instead of just loading the full and big images from Magento this extension resizes the images. This works by passing the Magento image path through the image route: /storage/{store id}/resizes/{size}/magento/{file}.
Let's say a product image is located at: https://magentowebsite.com/media/catalog/product/a/a/product-image.jpg the path will be /catalog/product/a/a/product-image.jpg. To get this image with a maximum width of 200 pixels you go to: /storage/1/resizes/200/magento/catalog/product/a/a/product-image.jpg. If you also want to specify a maximum height: /storage/1/resizes/200x200/magento/catalog/product/a/a/product-image.jpg.
Automatic webp conversion will also be done if the url has .webp as it's extension e.g. /storage/1/resizes/200x200/magento/catalog/product/a/a/product-image.jpg.webp
This will make it retrieve the image from https://magentowebsite.com/media/catalog/product/a/a/product-image.jpg, resize it, format it as webp and save it as /storage/1/resizes/200x200/magento/catalog/product/a/a/product-image.jpg.webp.
Installation
This package is installed by default in Rapidez. But if removed you can re-install it with:
composer require rapidez/image-resizer
And make sure you ran php artisan storage:link
Image from SKU
You can retrieve a product image by using the product's SKU. This is enabled by default, but can be toggled with the sku.enabled value in the config file.
To retrieve a product image using SKU, request a path like this: /storage/1/resizes/200x200/sku/13706. You can also request a webp like this: /storage/1/resizes/200x200/sku/13706.webp.
Config
Keep in mind that you have to whitelist all sizes to avoid ddos attacks! Publish the config and specify the sizes you want:
php artisan vendor:publish --provider="Rapidez\ImageResizer\ImageResizerServiceProvider" --tag=config
External sources
If you are using images from other external location (see the CMS integrations) you can add that source:
'external' => [
'strapi' => env('STRAPI_URL'),
],
Now you can use the following path to resize the images from the external source:
<img src="{{ '/storage/' . config('rapidez.store') . '/resizes/<size>/strapi'.$data->image->url }}" />
Or alternatively using Laravels route function
<img src="{{ route('resized-image', [ 'store' => config('rapidez.store'), 'size' => '<size>', 'placeholder' => 'strapi', 'file' => $data->image->url ]) }}" />
How it works
Images are downloaded from the media url and stored in /storage/app/public/<store>/resizes. Because of the symlink created with php artisan storage:link the files are then publicly available. Because the route is the same as the path, the webserver first tries to serve the file if it exists, otherwise it will go through PHP to resize and create it.
Deleting resizes
The image resizes can be deleted using this artisan command:
php artisan rapidez:resizes:delete {store?}
License
GNU General Public License v3. Please see License File for more information.
rapidez/image-resizer 适用场景与选型建议
rapidez/image-resizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.08k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rapidez」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rapidez/image-resizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rapidez/image-resizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rapidez/image-resizer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Rapidez Reviews
Rapidez Experius Postcode NL implementation
Rapidez Amasty Label
Rapidez MSI
Rapidez MagePrince Faq
Implements VIES validation to use on VAT fields in Rapidez
统计信息
- 总下载量: 21.08k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 18
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-or-later
- 更新时间: 2021-06-30