Fuel Assets Class
Ths class is used to help manage asset files.
This class extends the Fuel_base_library class.
Properties Reference
Property | Default Value | Description |
---|---|---|
public | ||
dir_filetypes |
array('images' => 'jpg|jpeg|jpe|gif|png|zip|svg', 'pdf' => 'pdf|zip', 'media' => 'mov|mp3|aiff|mpeg|zip', 'assets' => 'jpg|jpeg|jpe|png|gif|mov|mpeg|mp3|wav|aiff|pdf|css|zip|svg', ) |
The default file types to associate with asset different asset folders |
protected | ||
_data | N/A | Holds uploaded file data |
_dirs | N/A | The directories the CMS has access to upload files |
Function Reference [+]
$this->fuel->assets->initialize([$params=array()])
Initialize the object and set object parameters. Accepts an associative array as input, containing object preferences. Also will set the values in the parameters array as properties of this object.
Returns
void
Parameters
(array) $params Array of initalization parameters (optional)
$this->fuel->assets->upload([$params=array()])
Uploads the files in the $_FILES array. Accepts an associative array as which can have the following parameters:
- upload_path: the server path to upload the file
- override_post_params: determines whether post parameters (e.g. {$_FILES_key}_{param}) take precedence over parameters passed to the method
- file_name: the name of the file to change to
- overwrite: boolean value that determines whether to overwrite the file or create a new file which will append a number at the end
- xss_clean: boolean value that determines whether to try and run the xss_clean function on any images that are uploaded
- encrypt_name: boolean value that determines whether to encrypt the file name and make it unique
- create_thumb: image specific boolean value that determines whether to create a thumbnail image based on the original uploaded image
- thumb_marker: the default suffix to use on a generated thumbnail. The default is "_thumb"
- maintain_ratio:image specific boolean value that determines whether to maintain the aspect ratio of the image upon resize
- master_dim: image specific boolean value that determines which dimension should be used when resizing and maintaining the aspect ratio. Options are height, width, auto
- width: sets the width of the uploaded image
- height: sets the height of the uploaded image
- resize_and_crop: image specific boolean value that determines whether to both resize and crop the image to the specified height and width
Returns
boolean
Parameters
(array) $params upload parameters (optional)
$this->fuel->assets->sanitize_filename('$file_name')
Removes periods from the file name to mimic the CI Upload class and. runs the security sanitize_filename on the passed string.
Returns
string
Parameters
(string) $file_name The file name to clean
$this->fuel->assets->uploaded_data(['$key'=NULL])
Returns the uploaded file information.
Returns
array
Parameters
(string) $key The uploaded $_FILE key value (optional)
$this->fuel->assets->normalize_files_array()
$this->fuel->assets->file_info('$file')
Alias to the model's find_by_key method.
Returns
object
Parameters
(string) $file
$this->fuel->assets->delete('$file')
Alias to the model's delete method.
Returns
object
Parameters
(string) $file
$this->fuel->assets->model()
Returns the asset model.
Returns
object
$this->fuel->assets->dir('$dir')
Returns an asset folder name.
Returns
string
Parameters
(string) $dir The key associated with the asset folder (usually the same as the asset folder's name)
$this->fuel->assets->dirs()
Returns an array of all the asset folders.
Returns
array
$this->fuel->assets->root_dirs(['$full_path'=FALSE])
Returns an array of the main root asset folders.
Returns
array
$this->fuel->assets->image_dir()
Returns the image asset folder name.
Returns
string
$this->fuel->assets->dir_filetypes(['$return_array'=FALSE])
Returns an array of pipe delimited file types associated with assets.
Returns
mixed
Parameters
(boolean) $return_array returns an array instead of the pipe delimited list. Default is FALSE
$this->fuel->assets->dir_filetype('$filetype', ['$return_array'=FALSE])
Returns a list of file types that are allowed for a particular folder.
Returns
mixed
Parameters
(string) $filetype folder name (boolean) $return_array returns an array instead of the pipe delimited list. Default is FALSE
$this->fuel->assets->dir_files('$folder', ['$recursive'=FALSE], ['$append_path'=FALSE])
Returns a list of file types that are allowed for a particular folder.
Returns
mixed
Parameters
(string) $folder folder name (boolean) $recursive will recursively look inside nested folders. Default is FALSE (boolean) $append_path will include the server path. Default is FALSE
$this->fuel->assets->excluded_asset_server_folders()
An array of folders excluded from being viewed.
Returns
array
$this->fuel->assets->zip('$dir', ['$file_name'=NULL], ['$download'=FALSE], ['$allow_overwrite'=TRUE])
Zips up an asset folder.
Returns
string
Parameters
(mixed) $dir If a string, it should be the folder path. If an array, it will be extracted and must at least contain a key of "dir" that specifies the folder path (string) $file_name File name (boolean) $download Determines whether to send download headers to the browser (boolean) $allow_overwrite Allow a file with the same name as the zip to be overwritten
$this->fuel->assets->unzip('$zip_file', ['$destination'=NULL])
Unzips a zip file.
Returns
array An array of unzipped file names
Parameters
(string) $zip_file The path to the zip file to unzip relative to the assets folder (string) $destination The destination path