unclecheese / silverstripe-image-optionset
提供了一组可选择的项,这些项使用图像作为主要标签而不是文本。
2.0
2018-02-09 11:01 UTC
Requires
This package is auto-updated.
Last update: 2024-08-29 04:42:52 UTC
README
提供了一组可选择的项,这些项使用图像作为主要标签而不是文本。
屏幕截图
安装
composer require unclecheese/silverstripe-image-optionset
配置
您可以配置图像的默认宽度和高度。
UncleCheese\Forms\ImageOptionsetField: default_image_width: 300 default_image_height: 300
使用方法
简单示例
$field = ImageOptionsetField::create('Template', 'Select a template') ->setSource([ 'sidebar' => [ 'title' => 'Sidebar page', 'image' => '/path/to/sidebar.png' ], 'block' => [ 'title' => 'Block page', 'image' => '/path/to/block.png' ] ]); // Use a custom image width and height $field->setImageWidth(100); $field->setImageHeight(100);
如果您不使用标题,可以使用图像路径作为值而不是嵌套数组。
$field = ImageOptionsetField::create('Template', 'Select a template') ->setSource([ 'sidebar' => '/path/to/sidebar.png' 'block' => '/path/to/block.png' ]);
测试
tests/ImageOptionsetFieldTest
故障排除
联系Uncle Cheese。