PHP Class RTMediaMedia, rtMedia

Author: Udit Desai ([email protected])
Show file Open project: rtCamp/rtMedia Class Usage Examples

Public Properties

Property Type Description
$default_object
$model DB Model object to interact on Database operations

Public Methods

Method Description
__construct ( ) Initialises the model object of the mediua object
activity_enabled ( ) : boolean Check if BuddyPress and the activity component are enabled
add ( type $uploaded, type $file_object ) : type Generic method to add a media
add_meta ( array $attachments, array $custom_fields ) : boolean
add_taxonomy ( array $attachments, array $taxonomies ) Adds taxonomy
delete ( integer $id, boolean $core = false, boolean $delete_activity = true ) : boolean Generic method to delete a media
delete_hook ( ) Adds a hook to delete_attachment tag called when a media is deleted externally out of rtMedia context
delete_wordpress_attachment ( integer $id ) : boolean Generic method to delete a media from wordpress media library ( other than by rtMedia )
generate_post_array ( type $uploaded, type $file_object ) : type
image_sizes ( type $sizes ) : type
import_attachment ( ) Imports attachment as media
insert_activity ( $id, $media, $activity_text = false )
insert_album ( type $attributes ) : integer
insert_attachment ( type $attachments, type $file_object ) : array
insertmedia ( array $attachment_ids, array $uploaded, $file_object ) : array
is_multisite ( ) : boolean Helper method to check for multisite - will add a few additional checks for handling taxonomies
media_nonce_generator ( $id, boolean $echo = true ) : string Generate nonce
move ( type $media_id, type $album_id ) : boolean Move a media from one album to another
reassign_wordpress_user ( integer $user_id, $reassign ) Method to reassign media to another user while deleting user
set_media_type ( $mime_type, $file_object )
update ( $id, $data, integer $media_id ) : boolean Generic method to update a media. media details can be changed from this method
verify_nonce ( string $mode ) : boolean Method verifies the nonce passed while performing any CRUD operations on the media.

Method Details

__construct() public method

Initialises the model object of the mediua object
public __construct ( )

activity_enabled() public method

Check if BuddyPress and the activity component are enabled
public activity_enabled ( ) : boolean
return boolean

add() public method

Generic method to add a media
public add ( type $uploaded, type $file_object ) : type
$uploaded type
$file_object type
return type

add_meta() public method

public add_meta ( array $attachments, array $custom_fields ) : boolean
$attachments array attachment ids
$custom_fields array array of key value pairs of meta
return boolean success of meta

add_taxonomy() public method

Adds taxonomy
public add_taxonomy ( array $attachments, array $taxonomies )
$attachments array ids of the attachments created after upload
$taxonomies array array of terms indexed by a taxonomy

delete() public method

Generic method to delete a media
public delete ( integer $id, boolean $core = false, boolean $delete_activity = true ) : boolean
$id integer
$core boolean
$delete_activity boolean
return boolean

delete_hook() public method

Adds a hook to delete_attachment tag called when a media is deleted externally out of rtMedia context
public delete_hook ( )

delete_wordpress_attachment() public method

Generic method to delete a media from wordpress media library ( other than by rtMedia )

generate_post_array() public method

public generate_post_array ( type $uploaded, type $file_object ) : type
$uploaded type
$file_object type
return type

image_sizes() public method

public image_sizes ( type $sizes ) : type
$sizes type
return type

import_attachment() public method

Imports attachment as media
public import_attachment ( )

insert_activity() public method

public insert_activity ( $id, $media, $activity_text = false )

insert_album() public method

public insert_album ( type $attributes ) : integer
$attributes type
return integer

insert_attachment() public method

public insert_attachment ( type $attachments, type $file_object ) : array
$attachments type
$file_object type
return array $updated_attachment_ids

insertmedia() public method

public insertmedia ( array $attachment_ids, array $uploaded, $file_object ) : array
$attachment_ids array
$uploaded array
$file_object
return array

is_multisite() public method

Helper method to check for multisite - will add a few additional checks for handling taxonomies
public is_multisite ( ) : boolean
return boolean

media_nonce_generator() static public method

Generate nonce
static public media_nonce_generator ( $id, boolean $echo = true ) : string
$echo boolean whether nonce should be echoed
return string json encoded nonce

move() public method

Move a media from one album to another
public move ( type $media_id, type $album_id ) : boolean
$media_id type
$album_id type
return boolean

reassign_wordpress_user() public method

Method to reassign media to another user while deleting user
public reassign_wordpress_user ( integer $user_id, $reassign )
$user_id integer , $reassign

set_media_type() public method

public set_media_type ( $mime_type, $file_object )

update() public method

Generic method to update a media. media details can be changed from this method
public update ( $id, $data, integer $media_id ) : boolean
$id
$data
$media_id integer
return boolean

verify_nonce() public method

Method verifies the nonce passed while performing any CRUD operations on the media.
public verify_nonce ( string $mode ) : boolean
$mode string The upload mode
return boolean whether the nonce is valid

Property Details

$default_object static public property

static public $default_object

$model public property

DB Model object to interact on Database operations
public $model