Media | Flextype

Media

Core Concepts

Methods

Media Files

Method Description
upload() Upload media file.
fetch() Fetch file(s).
fetchSingle() Fetch single file.
fetchCollection() Fetch files collection.
rename() Rename file.
delete() Delete file.
has() Check whether a file exists.
getFileLocation() Get file location.

Methods Details

upload()

Upload media file.

Examples

flextype('media_files')->upload($_FILES['file'],
                                            '/entries/movies/sg-1/season-5/episode-21/');
fetch()

Fetch file(s).

Examples

// Fetch single image
$cover = flextype('media_files')->fetch('entries/movies/sg-1/season-5/episode-21/cover.jpg');

// Now you may get each image field from image meta data.
echo $cover['title'];
echo $cover['description'];
echo $cover['uploaded_on'];
echo $cover['filename'];
echo $cover['basename'];
echo $cover['extension'];
echo $cover['dirname'];
echo $cover['url'];
echo $cover['full_url'];

// Fetch images collection
$images = flextype('media_files')->fetch('entries/movies/sg-1/season-5/episode-21/images/');
fetchSingle()

Fetch single file.

Examples

// Fetch single image
$cover = flextype('media_files')->fetch('entries/movies/sg-1/season-5/episode-21/cover.jpg');

// Now you may get each image field from image meta data.
echo $cover['title'];
echo $cover['description'];
echo $cover['uploaded_on'];
echo $cover['filename'];
echo $cover['basename'];
echo $cover['extension'];
echo $cover['dirname'];
echo $cover['url'];
echo $cover['full_url'];
fetchCollection()

Fetch files collection.

Examples

// Fetch images collection
$images = flextype('media_files')->fetchCollection('entries/movies/sg-1/season-5/episode-21');
rename()

Rename file.

Examples

flextype('media_files')
            ->rename('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                          'entries/movies/sg-1/season-5/episode-21/cover-image.jpg');
delete()

Delete file.

Examples

flextype('media_files')
            ->delete('entries/movies/sg-1/season-5/episode-21/cover-image.jpg');
has()

Check whether a file exists.

Examples

if (flextype('media_files')
            ->has('entries/movies/sg-1/season-5/episode-21/cover-image.jpg')) {
    // do something...
}
getFileLocation()

Get file location.

Examples

flextype('media_files')
            ->getFileLocation('entries/movies/sg-1/season-5/episode-21/cover-image.jpg');

Media Files Meta

Method Description
update() Update file meta information.
add() Add file meta information.
delete() Delete file meta information.
getFileMetaLocation() Get file meta location.

Methods Details

update()

Update file meta information.

Examples

flextype('media_files_meta')
            ->update('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'title',
                     'Episode 21');
add()

Add file meta information.

Examples

flextype('media_files_meta')
            ->add('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'tags',
                     'sg1');
delete()

Delete file meta information.

Examples

flextype('media_files_meta')
            ->delete('entries/movies/sg-1/season-5/episode-21/cover.jpg',
                     'tags');
getFileMetaLocation()

Get file meta location.

Examples

flextype('media_files_meta')
            ->getFileMetaLocation('entries/movies/sg-1/season-5/episode-21/cover.jpg');

Media Folders

Method Description
fetch() Fetch folder(s).
fetchSingle() Fetch single folder.
fetchCollection() Fetch folders collection.
rename() Create folder.
rename() Rename folder.
delete() Delete folder.
getDirLocation() Get folder location.

Methods Details

fetch()

Fetch folder(s).

Examples

// Fetch single folder
$folder = $flextype
                ->media_folders
                ->fetch('entries/movies/sg-1/season-5/episode-21');

echo $folder['path'];
echo $folder['full_path'];
echo $folder['url'];
echo $folder['full_url'];

// Fetch folders collection
$folders = $flextype
                ->media_folders
                ->fetch('entries/movies/sg-1/season-5', true);
fetchSingle()

Fetch single folder.

Examples

// Fetch single folder
$folder = $flextype
                ->media_folders
                ->fetchSingle('entries/movies/sg-1/season-5/episode-21');

echo $folder['path'];
echo $folder['full_path'];
echo $folder['url'];
echo $folder['full_url'];
fetchCollection()

Fetch folders collection.

Examples

// Fetch folders collection
$folders = $flextype
                ->media_folders
                ->fetchCollection('entries/movies/sg-1/season-5');
create()

Create folder.

Examples

flextype('media_folders')
            ->create('entries/movies/sg-1/season-5/episode-22');
rename()

Rename folder.

Examples

flextype('media_folders')
            ->rename('entries/movies/sg-1/season-5/episode-22',
                            'entries/movies/sg-1/season-5/episode-23');
delete()

Delete folder.

Examples

flextype('media_folders')
            ->delete('entries/movies/sg-1/season-5/episode-23');
getDirLocation()

Get folder location.

Examples

flextype('media_folders')
            ->getDirLocation('entries/movies/sg-1/season-5/episode-23');

Media Folders Meta

Method Description
getDirMetaLocation() Get files directory meta location.

Methods Details

getDirMetaLocation()

Get files directory meta location.

Examples

flextype('media_folders_meta')
            ->getDirMetaLocation('entries/movies/sg-1/season-5/episode-23');
Language: en, ru