struct DynFork::Fields::ImageField

Overview

Image upload field.

NOTE How to use, see example.

Defined in:

dynfork/fields/image.cr

Constructors

Instance Method Summary

Instance methods inherited from struct DynFork::Fields::Field

choices_from_json(json : String) : Nil choices_from_json, disabled=(disabled : Bool) disabled=, disabled? : Bool disabled?, errors : Array(String) errors, errors=(errors : Array(String)) errors=, field_type : String field_type, group : UInt8 group, hide=(hide : Bool) hide=, hide? : Bool hide?, hint : String hint, id : String id, id=(id : String) id=, ignored? : Bool ignored?, label : String label, name : String name, name=(name : String) name=, slug_sources : Array(String) slug_sources, warning : Array(String) warning, warning=(warning : Array(String)) warning=

Constructor methods inherited from struct DynFork::Fields::Field

new(pull : JSON::PullParser) new

Constructor Detail

def self.new(pull : JSON::PullParser) #

[View source]
def self.new(label : String = "", default : String | Nil = nil, placeholder : String = "", target_dir : String = "images", thumbnails : Array(Tuple(String, Int32)) | Nil = nil, maxsize : Int64 = 2097152, hide : Bool = false, required : Bool = false, disabled : Bool = false, readonly : Bool = false, ignored : Bool = false, hint : String = "", warning : Array(String) = Array(String).new) #

[View source]

Instance Method Detail

def accept : String #

HTML attribute: accept.
Describing which file types to allow.
Example: "image/png,image/jpeg,image/webp"

NOTE https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept#unique_file_type_specifiers


[View source]
def default : String | Nil #

Default file path.
Example: "public/media/default/noavatar.jpg"


[View source]
def default? : String | Nil | Nil #

Default file path.
Example: "public/media/default/noavatar.jpg"


[View source]
def extract_images_dir_path? : String | Nil #

[View source]
def extract_img_data? : DynFork::Globals::ImageData | Nil #

[View source]
def field_type : String #

Field type - Structure Name.


[View source]
def from_base64(base64 : String | Nil = nil, filename : String | Nil = nil, delete : Bool = false) : Nil #

Convert base64 to a image and save in the target directory. filename: Example: foo.pdf


[View source]
def from_path(path : String | Nil = nil, delete : Bool = false) : Nil #

Convert path to a image and save in the target directory.


[View source]
def group : UInt8 #

To optimize field traversal in the paladins/check() method.

WARNING It is recommended not to change.


[View source]
def input_type : String | Nil #

Html tag: input type="file".


[View source]
def input_type? : String | Nil | Nil #

Html tag: input type="file".


[View source]
def maxsize : Int64 #

The maximum allowed image size in bytes.

NOTE 1 MB = 1048576 Bytes (in binary).


[View source]
def media_root : String #

Root directory for storing media files.


[View source]
def media_root=(media_root : String) #

Root directory for storing media files.


[View source]
def media_url : String #

URL address for the media directory.


[View source]
def placeholder : String #

Displays prompt text.


[View source]
def readonly=(readonly : Bool) #

Specifies that the field cannot be modified by the user.


[View source]
def readonly? : Bool #

Specifies that the field cannot be modified by the user.


[View source]
def refrash_val_img_data(val : DynFork::Globals::ImageData) : Nil #

[View source]
def required? : Bool #

Required field.


[View source]
def target_dir : String #

Directory for images inside media directory.
Examples: avatars|photos|images


[View source]
def thumbnails : Array(Tuple(String, Int32)) | Nil #

From one to four inclusive.
Example: [{"xs", 150}, {"sm", 300}, {"md", 600}, {"lg", 1200}]


[View source]
def thumbnails? : Array(Tuple(String, Int32)) | Nil | Nil #

From one to four inclusive.
Example: [{"xs", 150}, {"sm", 300}, {"md", 600}, {"lg", 1200}]


[View source]
def value : DynFork::Globals::ImageData | Nil #

Sets the value of an element.


def value=(value : DynFork::Globals::ImageData | Nil) #

Sets the value of an element.


[View source]
def value? : DynFork::Globals::ImageData | Nil | Nil #

Sets the value of an element.