Filters

rtawss3_delete_bucket_table_entries

By default, rtAmazon s3 do not delete bucket table entries if it do not find the bucket on s3. If you want to delete the table entries then pass false to this filter.

add_filter( 'rtawss3_delete_bucket_table_entries', 'rtawss3_filter_to_delete_bucket_table_entries',10,1);
function rtawss3_filter_to_delete_bucket_table_entries( $flag ){
    $flag = false;
    return $flag;
}

replace_aws_img_urls_from_activities

If media URLs are getting broken on your activity page then please apply the following filter.

/**
 * Prevent changing urls of activity image
 *
 * @return bool return true if buddypress multisite is enabled.
 */
function rtmedia_buddypress_mu_enabled() {
    return true;
}
add_filter( 'replace_aws_img_urls_from_activities', 'rtmedia_buddypress_mu_enabled' );

rtawss3_before_virtual_folder_path

You can use this filter and update the folder path according to your requirement.

function custom_rtawss3_before_virtual_folder_path( $prefix, $path_info ){
    $prefix = 'my/new/path/';
    return $prefix;
}
add_filter( 'rtawss3_before_virtual_folder_path', 'custom_rtawss3_before_virtual_folder_path', 10, 2 );

rtawss3_get_attachment_url

By default, the URLs returned by the AWS API are HTTPS URLs. If you want to use HTTP version of the URLs, you can use this filter. Using this filter you will get the HTTP version of the URL if your site us using/running on HTTP or you will get HTTPS version of the URL if you have SSL configured site.

function custom_rtawss3_get_attachment_url(){
    return true;
}
add_filter( 'rtawss3_get_attachment_url', 'custom_rtawss3_get_attachment_url', 10 );

rtawss3_can_upload_to_bucket

Exclude certain file types (videos for example) from being uploaded to the S3 bucket..

function rtamazon_can_upload_to_bucket( $status, $attachment_id ) {

     // Get the mime type for uploading media.
     $mime_type = get_post_mime_type( $attachment_id );
     $type_arr = explode( '/' , $mime_type );

     // Get media type.
     $type = $type_arr[0];

     // Check if it is video type, then skip uploading to bucket.
     // Other types you can define i.e 'image', 'audio' etc.
     if ( ! empty( $type ) && 'video' === $type ) {
         $status = false;
     }

     return $status;

}
add_filter( 'rtawss3_can_upload_to_bucket', 'rtamazon_can_upload_to_bucket', 99, 2 );

rtawss3_is_bucket_allow

Use this filter if you want to customise the bucket listing under the rtAmazon s3 admin setting. Here, is the example which will only display a single bucket name in the drop-down. You need to add your bucket name which you want to display by replacing the text YOUR BUCKET NAME from below snippet

NOTE: If you add a bucket name which is not on your bucket list, then no buckets will become empty.

/**
 * Show particular bucket to bucket list.
 *
 * @param bool  $status default status true.
 *
 * @param array $bucket Array of bucket details.
 */
function rtawss3_my_bucket_allow( $status, $bucket ) {

	/**
	 * Allowed buckets.
	 * Multiple bucket name can be added with comma separated names -
	 * enclosed in single quotes - 'YOUR 1st BUCKET NAME' , 'YOUR 2nd BUCKET NAME'
	 */
	$allowed_buckets = array( 'YOUR BUCKET NAME' );

	// If bucket is not allowed, then don't show it into dropdown.
	if ( ! empty( $allowed_buckets ) && ! in_array( $bucket['Name'], $allowed_buckets ) ) {
		return false;
	}

	return $status;

}
add_filter( 'rtawss3_is_bucket_allow', 'rtawss3_my_bucket_allow', 10, 2 );

rtawss3_put_object_additional_params

Use this filter to add extra header information with media files to be uploaded on S3. Do not put - in parameter name.
Example: Use CacheControl instead of Cache-Control.

NOTE: This filter has been added with rtAmazon S3 plugin version 1.5.3. Thus, the below sample code will work only for the same or higher versions of the plugin.

/**
 * Add header information in uploading media on S3.
 *
 * @param  array $additional_param Variable to store additional prameter of S3 putObject method.
 * @return array
 */
function set_additional_put_object_parameter( $additional_param = array() ) {

        $additional_param['CacheControl'] = 'max-age=604800';

        return $additional_param;
}

add_filter( 'rtawss3_put_object_additional_params', 'set_additional_put_object_parameter' );