From 83c939f2d3fc796b58c194895c3245f74bcdb9da Mon Sep 17 00:00:00 2001 From: janhartigan Date: Thu, 22 Jan 2015 16:41:29 -0800 Subject: [PATCH] setting up raw values for image and file fields --- changelog.md | 2 ++ docs/field-type-file.md | 3 +++ docs/field-type-image.md | 3 +++ src/Frozennode/Administrator/Fields/File.php | 1 + src/views/templates/edit.php | 16 ++++++++++++++-- 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 39a3bb61f..8e52c7ee1 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ ## Changelog +- It's now possible to use the raw value of a file/image field to help with storing files on remote servers. + ### 4.15.0 - New uneditable states for color, password, enum, and wysiwyg fields for when the editable option resolves to false - New translations (sk) diff --git a/docs/field-type-file.md b/docs/field-type-file.md index 28f645c38..45b61d759 100644 --- a/docs/field-type-file.md +++ b/docs/field-type-file.md @@ -16,6 +16,7 @@ The `file` field type should be a text-like type in your database. The file's na 'naming' => 'random', 'length' => 20, 'size_limit' => 2, + 'display_raw_value' => false, 'mimes' => 'pdf,psd,doc', ) @@ -29,4 +30,6 @@ The optional `length` option lets you define size of file name in case `random` 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 (which you can do in your php.ini). +The optional `display_raw_value` option lets you put the raw value of the saved file source string into the displayed file link. This is useful if you're using accessors, mutators, and [`setter fields`](/docs/fields#setter-option) to skip storing the file on your local server and instead upload it to a remote public file server. + The optional `mimes` option by default allows all file types. This uses Laravel's [mimes validation](http://laravel.com/docs/validation#rule-mimes), which in turn uses the PHP Fileinfo extension to read the contents of the file and determine the actual MIME type. \ No newline at end of file diff --git a/docs/field-type-image.md b/docs/field-type-image.md index 808629c58..de0c1c1cb 100644 --- a/docs/field-type-image.md +++ b/docs/field-type-image.md @@ -16,6 +16,7 @@ The `image` field type should be a text-like type in your database. The image's '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), @@ -33,4 +34,6 @@ The optional `length` option lets you define size of file name in case `random` 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`](/docs/fields#setter-option) 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`. \ No newline at end of file diff --git a/src/Frozennode/Administrator/Fields/File.php b/src/Frozennode/Administrator/Fields/File.php index 4cc4b1d9a..3cde16662 100644 --- a/src/Frozennode/Administrator/Fields/File.php +++ b/src/Frozennode/Administrator/Fields/File.php @@ -15,6 +15,7 @@ class File extends Field { 'length' => 32, 'mimes' => false, 'size_limit' => 2, + 'display_raw_value' => false, ); /** diff --git a/src/views/templates/edit.php b/src/views/templates/edit.php index 5147956e5..e569a7859 100644 --- a/src/views/templates/edit.php +++ b/src/views/templates/edit.php @@ -195,7 +195,13 @@
- + + + + + + + @@ -221,8 +227,14 @@
- + + + + +