本书未发布

字段:图片 Image

未匹配的标注

文档尚未来得及翻译,欢迎以改进的方式提交译文。

Field Type - Image

Usage

field-type-image.jpg

The image field type should be a text-like type in your database. The image's file name is stored in this field, while the original will be saved in the location you specify, and any resized copies will be stored where you define in the sizes option.

'image' => array(
    'title' => 'Image',
    'type' => 'image',
    'location' => public_path() . '/uploads/products/originals/',
    'naming' => 'random',
    'length' => 20,
    'size_limit' => 2,
    'display_raw_value' => false,
    'sizes' => array(
        array(65, 57, 'crop', public_path() . '/uploads/products/thumbs/small/', 100),
        array(220, 138, 'landscape', public_path() . '/uploads/products/thumbs/medium/', 100),
        array(383, 276, 'fit', public_path() . '/uploads/products/thumbs/full/', 100)
    )
)

In the edit form, an admin user will be presented with an image uploader. For the moment, this uploader only allows one image to be uploaded at a time.

The required location option lets you define where the original image should be stored.

The optional naming option lets you define whether to keep the file's name or to make the file name random. By default this is set to random in order to avoid naming collisions, but setting this to keep lets you keep your image's file names.

The optional length option lets you define size of file name in case random is supplied as naming option method.

The optional size_limit option lets you set an integer size limit counted in megabytes. This only affects the JavaScript file uploading dialog, it doesn't limit your PHP upload sizes.

The optional display_raw_value option lets you put the raw value of the saved image source string into the image input. This is useful if you're using accessors, mutators, and setter fields to skip storing the image on your local server and instead upload it to a remote public image server.

The optional sizes option lets you define as many resizes as you want. The format for these is: array([width], [height], [method], [save path], [quality]). The different methods are exact, portrait, landscape, fit, auto, and crop.

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
Summer
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 0
发起讨论 只看当前版本


暂无话题~