- rtm_other_file_js_strings
- rtmedia_other_type_slug
- rtmedia_documents_slug
- rtmedia_disable_google_doc_service
- rtmedia_other_files_document_other_files_list_date_filter
- rtm_docs_file_add_column
- rtm_docs_viewer_html
Description
Filter to modify js messages for docs-other-files plugin.
add_filter('rtm_other_file_js_strings', 'rtmedia_other_file_js_strings' );
function rtmedia_other_file_js_strings ( $rtmedia_other_files_main_js ) {
$rtmedia_other_files_main_js['rtmedia_file_not_deleted'] = 'Enable to delete document.';
return $rtmedia_other_files_main_js;
}
Filter to modify Creates slug for other type files.
add_filter( 'rtmedia_other_type_slug', 'rtm_other_type_slug', 10, 1 );
function rtm_other_type_slug ( $slug ) {
return 'other';
}
Filter to modify slug for document type files.
add_filter( 'rtmedia_documents_slug', 'rtm_documents_type_slug', 10, 1 );
function rtm_documents_type_slug ( $slug ) {
return 'document';
}
Filter to modify google docs service disabled message.
add_filter( 'rtmedia_disable_google_doc_service', 'rtm_disable_google_doc_service', 10, 1 );
function rtm_disable_google_doc_service ( $msg ) {
return __( 'Docs service has been disabled. This file can\'t be loaded.', 'rtmedia' ) ;
}
Filter to modify documents and other file uploaded date in Table style list.
add_filter( 'rtmedia_other_files_document_other_files_list_date_filter', 'rtm_other_files_document_other_files_list_date_filter', 10, 1 );
function rtm_other_files_document_other_files_list_date_filter ( $date_time ) {
return $date_time;
}
Filter to add new column in table view style for document and other file types. Below example is to add column for Type of file and to add columns for Media author in table view style.
add_filter( 'rtm_docs_file_add_column', 'rtm_docs_file_add_column_type_owner', 10, 1 );
/**
* This function is to add column heading, class and callback function.
*/
function rtm_docs_file_add_column_type_owner( $column ) {
$column[] = array(
'columns' => 'Owner',
'class' => 'rtmedia-list-document-td-size',
'callback' => 'rtmedia_render_docs_owner_content',
);
$column[] = array(
'columns' => 'Type',
'class' => 'rtmedia-list-document-td-size',
'callback' => 'rtmedia_render_docs_type_content',
);
return $column;
}
/**
* This function is callback function for new column added using filter.
*/
function rtmedia_render_docs_type_content( $media_id ) {
$type = rtmedia_media_ext( $media_id );
echo '<td data-value="'. $type .'">'. $type .'</td>';
}
function rtmedia_render_docs_owner_content( $media_id ) {
global $rtmedia_media;
$type = rtmedia_get_author_name( $rtmedia_media->media_author );
echo '<td data-value="'. $type .'">'. $type .'</td>';
}
-
rtm_docs_viewer_html
Filter to change the default Google Docs Viewer.
add_filter( 'rtm_docs_viewer_html', 'rtm_docs_viewer_html_frame', 10, 3 );
function rtm_docs_viewer_html_frame( $html, $url, $att_id ) {
$html = '<iframe src="https://view.officeapps.live.com/op/view.aspx?src=' . urlencode( $url ) . '" class="rtm-google-doc-container"></iframe>';
return $html;
}
Use the following snippet to change the default doc viewer to the Live Office. This is handy if you need to add docs larger than the 20MB filesize limit imposed by Google Docs.
add_filter( 'rtm_docs_viewer_html', 'rtm_docs_viewer_html_frame', 10, 3 );
function rtm_docs_viewer_html_frame( $html, $url, $att_id ) {
$att_size = filesize( get_attached_file( $att_id ) );
$allow_media_size = 20;
/* check file size more then 20 MB or not */
if ( $att_size < $allow_media_size * 1048576 ) {
$html = '<iframe src="http://docs.google.com/viewer?url=' . $url . '&embedded=true" class="rtm-google-doc-container"></iframe>';
} else {
$html = '<iframe src="https://view.officeapps.live.com/op/view.aspx?src=' . urlencode( $url ) . '" class="rtm-google-doc-container"></iframe>';
}
return $html;
}