tibemolde/placeholder-pixel

创建指定宽度和高度的base64编码透明像素

v1.1.2 2018-02-15 11:35 UTC

This package is not auto-updated.

Last update: 2024-09-29 05:41:50 UTC


README

创建指定宽度和高度的base64编码透明像素

一旦生成像素,将根据宽度 * 高度进行缓存以减少负载

要求

此插件需要Craft CMS 3.0.0-RC1或更高版本。

安装

要安装插件,请按照以下说明操作。

  1. 打开您的终端并转到您的Craft项目

     cd /path/to/project
    
  2. 然后告诉Composer加载插件

     composer require tibemolde/placeholder-pixel
    
  3. 在控制面板中,转到设置 → 插件,然后点击“安装”按钮安装Placeholder Pixel。

Placeholder Pixel概述

创建指定宽度和高度的base64编码透明像素

配置Placeholder Pixel

除了运行时选项外,无需进行任何配置

使用Placeholder Pixel

基本用法

craft.placeholderPixel.get(options)

默认选项

{
    width       : 1,
    height      : 1,
    aspectRatio : {
        w: 16,
        h: 10
    }
}    

示例

  1. 1 x 1 像素

    <img src="{{ craft.placeholderPixel.get }}" alt="">
    
  2. 具有两个特定尺寸的像素

     <img src="{{ craft.placeholderPixel.get({width: 64, height: 64}) }}" alt="">
    
  3. 具有一个特定尺寸和默认宽高比的像素

     <img src="{{ craft.placeholderPixel.get({width: 1024}) }}" alt="">
    
  4. 具有一个特定尺寸和特定宽高比的像素

     <img src="{{ craft.placeholderPixel.get({width: 1024, aspectRatio: {w: 5, h: 4}}) }}" alt="">
    

Placeholder Pixel路线图

一些待办事项和潜在功能的想法

  • 如何让它变得更好? :o

TIBE Molde 提供