otago/silverstripe-retinaimages
Composer 安装命令:
composer require otago/silverstripe-retinaimages
包简介
An add-on for adaptive images.
关键字:
README 文档
README
An add-on for adaptive images
Makes your images look crisp and sexy on high DPI devices.
Usage
- run
composer require otago/silverstripe-retinaimages - run ?flush=1 on your page
All images used in your WYSIWYG editor should now be retina upscaled images
using srcset. you can check this by inspecting your tags
Using retina in the template
If you want retina images in your template, you specify this with prefixing all image functions with retina.
For example, $Image.Fill(50,50) becomes $Image.RetinaFill(50,50)
// Scaling functions
$Image.RetinaScaleWidth(150) // Returns a 150x75px image
$Image.RetinaScaleMaxWidth(100) // Returns a 100x50px image (like ScaleWidth but prevents up-sampling)
$Image.RetinaScaleHeight(150) // Returns a 300x150px image (up-sampled. Try to avoid doing this)
$Image.RetinaScaleMaxHeight(150) // Returns a 200x100px image (like ScaleHeight but prevents up-sampling)
$Image.RetinaFit(300,300) // Returns an image that fits within a 300x300px boundary, resulting in a 300x150px image (up-sampled)
$Image.RetinaFitMax(300,300) // Returns a 200x100px image (like Fit but prevents up-sampling)
// Warning: This method can distort images that are not the correct aspect ratio
$Image.RetinaResizedImage(200, 300) // Forces dimensions of this image to the given values.
// Cropping functions
$Image.RetinaFill(150,150) // Returns a 150x150px image resized and cropped to fill specified dimensions (up-sampled)
$Image.RetinaFillMax(150,150) // Returns a 100x100px image (like Fill but prevents up-sampling)
$Image.RetinaCropWidth(150) // Returns a 150x100px image (trims excess pixels off the x axis from the center)
$Image.RetinaCropHeight(50) // Returns a 200x50px image (trims excess pixels off the y axis from the center)
// Padding functions (add space around an image)
$Image.RetinaPad(100,100) // Returns a 100x100px padded image, with white bars added at the top and bottom
$Image.RetinaPad(100, 100, CCCCCC) // Same as above but with a grey background
How it works
Allows support for high-resolution displays by automatically creating different assets representing the same image. It specifies bitmapped images by adding a srcset attribute to the img element, as specified by the W3C draft http://www.w3.org/html/wg/drafts/srcset/w3c-srcset/
When creating a generated image it creates three different images, scaled up to the following factors: 1.0x, 1.5x, and 2.0x. The default generated image is also created, which is used as the src attribute. These image urls are then placed into the srcset tag.
It does it out the box on through the template, WYSIWYG requires a modification to your getCMSFields() method.
srcset Polyfills
Older browsers require a polyfill. All modern browsers support the tag
https://github.com/borismus/srcset-polyfill/ https://github.com/culshaw/srcset http://jimbobsquarepants.github.io/srcset-polyfill/
otago/silverstripe-retinaimages 适用场景与选型建议
otago/silverstripe-retinaimages 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.12k 次下载、GitHub Stars 达 5, 最近一次更新时间为 2014 年 07 月 29 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「images」 「silverstripe」 「retina」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 otago/silverstripe-retinaimages 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 otago/silverstripe-retinaimages 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 otago/silverstripe-retinaimages 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel Nova field for distribute your images as array of object.
Pexels API Client for www.pexels.com
Simple srcset integration with SilverStripe’s HTMLEditorField
A PHP command line tool for converting SVG images to a set of CSS icons (SVG & PNG, single icons and / or CSS sprites) with support for image optimization and Sass output
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
统计信息
- 总下载量: 6.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2014-07-29