Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#971 : Media support with BuddyPress message. #1089

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
cd80161
update rtm-bp-message-media
Mar 29, 2018
d8198a3
Add functionality of BuddyPress Message with media
malavvasita Apr 4, 2018
197512c
Add media button to Compose and Send reply tab in buddypress message
Mar 20, 2018
fd14247
Re arranged media button send reply tab in buddypress message
Mar 20, 2018
b1b0bbe
Add block for showing media
Mar 20, 2018
4c18d5b
Update in CSS and view of media in message
Mar 20, 2018
9ab062a
>git checkout app/assets/css/rtmedia.min.css
malavvasita Apr 4, 2018
55dd7ec
update with review changes and phpcs
malavvasita Apr 4, 2018
c1fa7bb
Updated files with necessary changes and review suggestions
malavvasita Apr 5, 2018
467714d
Add doc comment in index.php
malavvasita Apr 5, 2018
8998687
Update alignment and applied localization on strings
malavvasita Apr 5, 2018
16dd753
Update alignment fixes and review suggestions
malavvasita Apr 5, 2018
09420f6
Add comment for phpcs:ignore
malavvasita Apr 5, 2018
1c469fd
Fix for Doc comments and alignments
malavvasita Apr 6, 2018
31a55ca
Updated with CS and versioning control
malavvasita Apr 6, 2018
f0961e9
Fix CS where needed
malavvasita Apr 6, 2018
0a016c3
Fix CS in JS file
malavvasita Apr 6, 2018
4a92261
Fix PHPCS
malavvasita Apr 24, 2018
f450ec3
Update SASS files
malavvasita Apr 24, 2018
cabde02
GH #971: Add 'message-media' context to hide media from user profile.
yahilmadakiya May 17, 2018
ac23adb
remove demo image
Pradeep1308 Nov 19, 2021
f8658d2
fix media upload functionality in legacy
Pradeep1308 Nov 26, 2021
3f6b95f
merge pre-release
Pradeep1308 Nov 26, 2021
dd3e775
build assets
Pradeep1308 Nov 26, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/assets/css/rtmedia.css
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ body.media.buddypress {
padding: 0;
}

#rtmedia_uploader_filelist {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}

.rtmedia_bp_msg_media_upload_render {
display: inline;
float: left;
}

.rtmedia-list-item > a {
border: 0;
display: inline-block;
Expand Down Expand Up @@ -3014,6 +3027,7 @@ h2.rtm-gallery-title {
}
.rtmedia-upload-media-link {
cursor: pointer;
display: block;
}

a.rtmedia-upload-media-link {
Expand Down
2 changes: 1 addition & 1 deletion app/assets/css/rtmedia.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions app/assets/css/sass/_media-tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ h2.rtm-gallery-title {

.rtmedia-upload-media-link {
cursor: pointer;
display: block;
}

a.rtmedia-upload-media-link {
Expand Down
12 changes: 12 additions & 0 deletions app/assets/css/sass/_rtm.scss
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
}
}

// Rearranging media preview at uploading time below uploader in BuddyPress compose message
#rtmedia_uploader_filelist{
display: flex;
flex-wrap: wrap;
}

// Preview of attached media below uploader in BuddyPress media message
.rtmedia_bp_msg_media_upload_render{
display: inline;
float: left;
}

.rtmedia-list-item > a {
border: 0;
display: inline-block;
Expand Down
56 changes: 54 additions & 2 deletions app/assets/js/rtMedia.backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var uploaderObj;
var objUploadView;
var rtmedia_load_template_flag = true;
var rtmedia_add_media_button_post_update = false;

var msg_media_files = []; // To store media id in BP Message.

jQuery( document ).ready( function () {

Expand Down Expand Up @@ -598,7 +598,17 @@ jQuery( function( $ ) {
},
initialize: function( config ) {
this.uploader = new plupload.Uploader( config );
/*
/**
* var current_url will fetch present working area's address and we will find if it contains message in url though find variable.
* If message is there in URL then we need to mention that it is message.
* we have appended message:true in config.
*/
var current_url = document.URL, find= 'message';
if ( -1 !== current_url.indexOf( find ) ){
config.message = true;
}

/**
* 'ext_enabled' will get value of enabled media types if nothing is enabled,
* then an error message will be displayed.
*/
Expand Down Expand Up @@ -668,6 +678,18 @@ jQuery( function( $ ) {

uploaderObj.uploader.bind( 'UploadComplete', function( up, files ) {

// Success message for BudyyPress Media Message
if ( jQuery( '.rtm-media-msg-upload-button' ).length == 1 ) {
jQuery( '.rtm-media-msg-upload-button' ).html( '' );
jQuery( '.rtm-media-msg-upload-button' ).removeAttr( 'id' );
jQuery( '.rtm-media-msg-upload-button' ).html(
jQuery( '<p>', { id: 'rtm_bpm_success' } )
);
jQuery( '#rtm_bpm_success' ).css( {'background': '#98ef98', 'padding': '20px' } );
jQuery( '#rtm_bpm_success' ).append( 'Media has been attached with this message!' );
jQuery( '#send_reply_button').hide();
jQuery( '#send_reply_button_with_media').show();
}
activity_id = -1;
var hook_respo = rtMediaHook.call( 'rtmedia_js_after_files_uploaded' );
if ( typeof rtmedia_gallery_reload_on_upload != 'undefined' && rtmedia_gallery_reload_on_upload == '1' ) { //Reload gallery view when upload completes if enabled( by default enabled)
Expand Down Expand Up @@ -927,6 +949,11 @@ jQuery( function( $ ) {
};
} );

// This function will store hidden values of Media ID in Array
function store_array_in_hidden_field(){
jQuery("#rtm_bpm_uploaded_media").attr("value", msg_media_files.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jQuery("#rtm_bpm_uploaded_media").attr("value", msg_media_files.toString()); could be

jQuery( '#rtm_bpm_uploaded_media' ).attr( 'value', msg_media_files.toString() );

}

uploaderObj.uploader.bind( 'BeforeUpload', function( up, file ) {
// We send terms conditions data on backend to validate this on server side.
rtMediaHook.call( 'rtmedia_js_before_upload', { uploader: up, file: file, src: 'uploader' } );
Expand Down Expand Up @@ -964,6 +991,30 @@ jQuery( function( $ ) {
} );

uploaderObj.uploader.bind( 'FileUploaded', function( up, file, res ) {
var uploaded_response_data = JSON.parse( res.response );
if( uploaded_response_data.length<=0 ){
jQuery( '.rtm-media-msg-upload-button' ).html( '' );
jQuery( '.rtm-media-msg-upload-button' ).removeAttr( 'id' );
jQuery( '.rtm-media-msg-upload-button' ).html(
jQuery( '<p>', { id: 'rtm_bpm_success' } )
);
jQuery( '#rtm_bpm_success' ).css(
{ 'background: #db001e':'#db001e', 'padding':'20px' }
);
jQuery( '#rtm_bpm_success' ).append(
rtmedia_backbone_strings.rtm_bp_msg_media_failure
);
} else {
msg_media_files.push( uploaded_response_data['media_id'] );
jQuery( '#rtm_bpm_uploaded_media' ).val(
jQuery( '#rtm_bpm_uploaded_media' ).val() ?
jQuery( '#rtm_bpm_uploaded_media' ).val() + ',' + uploaded_response_data[ 'media_id' ] :
uploaded_response_data[ 'media_id' ]
);
}

store_array_in_hidden_field();

if ( /MSIE (\d+\.\d+);/.test( navigator.userAgent ) ) { //Test for MSIE x.x;
var ieversion = new Number( RegExp.$1 ); // Capture x.x portion and store as a number

Expand Down Expand Up @@ -3010,3 +3061,4 @@ const rtMediaScrollComments = () => {
commentBox.scrollTo( { top: commentsToScroll, behavior: 'smooth' } );
}
}

4 changes: 3 additions & 1 deletion app/main/RTMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -1398,7 +1398,9 @@ public function enqueue_scripts_styles() {

// Localizing strings for rtMedia.backbone.js.
$rtmedia_backbone_strings = array(
'rtm_edit_file_name' => esc_html__( 'Edit File Name', 'buddypress-media' ),
'rtm_edit_file_name' => esc_html__( 'Edit File Name', 'buddypress-media' ),
'rtm_bp_msg_media_success' => esc_html__( 'Media has been attached with this message!', 'buddypress-media' ),
'rtm_bp_msg_media_failure' => esc_html__( 'Media attachement failed! Please try again!', 'buddypress-media' ),
);

// Localise fot rtmedia-backcone js.
Expand Down
11 changes: 11 additions & 0 deletions app/main/controllers/shortcodes/RTMediaGalleryShortcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,17 @@ public static function register_scripts() {
$request_uri = rtm_get_server_var( 'REQUEST_URI', 'FILTER_SANITIZE_URL' );
$url = rtmedia_get_upload_url( $request_uri );

/**
* @param array $url_array
* @param mixed $url
* Redirects to 'upload.php' when we are composing message and uplaod media with BP message
*/

if ( false !== strpos( $url, '/messages' ) ) {
$url_array = explode( '/messages', $url );
$url = trailingslashit( $url_array[0] ) . 'upload/';
}

$upload_max_size = ( wp_max_upload_size() ) / ( 1024 * 1024 ) . 'M';
$params = array(
'url' => $url,
Expand Down
2 changes: 1 addition & 1 deletion app/main/controllers/template/rtmedia-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ function is_rtmedia_privacy_enable() {
if ( isset( $rtmedia->options['privacy_enabled'] ) && 0 !== intval( $rtmedia->options['privacy_enabled'] ) ) {
return true;
}

return false;

}
Expand Down
5 changes: 5 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,11 @@ function rtmedia_autoloader( $class_name ) {
}
}

/**
* Allow media in BuddyPress message
*/
require_once RTMEDIA_PATH . '/templates/media/media-with-message.php';

/**
* Register the autoloader function into spl_autoload
*/
Expand Down
Loading