mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Setting SimpleImageField->allowedExtensions to sensible defaults
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63470 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
17aad01848
commit
b33aaf81ae
@ -1,13 +1,28 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* SimpleImageField provides an easy way of uploading images to Image has_one relationships.
|
* SimpleImageField provides an easy way of uploading images to {@link Image} has_one relationships.
|
||||||
|
* These relationships are auto-detected if you name the field accordingly.
|
||||||
* Unlike {@link ImageField}, it doesn't use an iframe.
|
* Unlike {@link ImageField}, it doesn't use an iframe.
|
||||||
*
|
*
|
||||||
|
* Restricts the upload size to 2MB by default, and only allows upload
|
||||||
|
* of files with the extension 'jpg', 'gif' or 'png'.
|
||||||
|
*
|
||||||
|
* Example Usage:
|
||||||
|
* <code>
|
||||||
|
* class Article extends DataObject {
|
||||||
|
* static $has_one = array('MyImage' => 'Image');
|
||||||
|
* }
|
||||||
|
* // use in your form constructor etc.
|
||||||
|
* $myField = new SimpleImageField('MyImage');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage fields-files
|
* @subpackage fields-files
|
||||||
*/
|
*/
|
||||||
class SimpleImageField extends FileField {
|
class SimpleImageField extends FileField {
|
||||||
|
|
||||||
|
public $allowedExtensions = array('jpg','gif','png');
|
||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
$record = $this->form->getRecord();
|
$record = $this->form->getRecord();
|
||||||
$fieldName = $this->name;
|
$fieldName = $this->name;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user