Welcome, Guest
Username Password: Remember me

BuddyPress Albums +
(1 viewing) (1) Guest
  • Page:
  • 1

TOPIC: BuddyPress Albums +

BuddyPress Albums + 5 years ago #65

  • cmstactics
  • OFFLINE
  • Administrator
  • Posts: 2
  • Karma: 0
Really wanted to continue using BP Albums but really needed the ability to have multiple albums as well as video support. We took an existing beta release from BP Media from Google Code which was versioned with stable tag of 0.1.6 but it was meant to be 0.1.9.2 which is understood to be a fork of BuddyPress Albums to allow support for multiple albums and videos and made it work. With the help of David Register from DavidMRegister.com and Alex from Alexiz.com we were able to see where the team left off and make it work for our site(s). The first site were we used this plugin is on a social network site called Baby U View. We needed FFMPEG installed on the server in order to allow thumbnails to be created from the video files that were uploaded. The plugin currently supports MP4, FLV, and MPEG. Therefore, the image generation will only work if FFMPEG is installed and we added our portion of the code in the functions.php of our themes directory. We are giving this out the to community and we want to give credit to those who wrote most of the code which are francescolaffi and foxly. Use at your own risk and if you have FFMPEG on your server you can copy this code into your functions.php.


function cmst_generate_thumb ( $source, $target, $width, $height ) {
        // Here we thumbnail our video
        $capture_image = 5;

        $extra = '-vframes 1 -s '.$width.'x'.$height.' -ss '.$capture_image.' -f image2';
        $str = "ffmpeg -y -i ".$source." ". $extra ." ".$target;
        return exec($str);
}
function cmst_thumb_for_video($data){
        $video_ext = array('mp4','flv','mpeg');
        $file_path = pathinfo($data->pic_org_url);
        $file_ext = $file_path['extension'];
        if(in_array($file_ext,$video_ext)){
                $file_org_path = pathinfo($data->pic_org_path);
                $file_org_url = pathinfo($data->pic_org_url);

                $lrg_img_path = $file_org_path['dirname'].'/'.$file_org_path['filename'].'-700x394.jpg';
                cmst_generate_thumb($data->pic_org_path,$lrg_img_path,700,394);

                $mid_img_path = $file_org_path['dirname'].'/'.$file_org_path['filename'].'-500x281.jpg';
                cmst_generate_thumb($data->pic_org_path,$mid_img_path,500,281);

                $sml_img_path = $file_org_path['dirname'].'/'.$file_org_path['filename'].'-240x135.jpg';
                cmst_generate_thumb($data->pic_org_path,$sml_img_path,240,135);

                $pic_pre_path = $file_org_path['dirname'].'/'.$file_org_path['filename'].'-150x150.jpg';
                cmst_generate_thumb($data->pic_org_path,$pic_pre_path,150,150);


                $pic_thumb_path = $file_org_path['dirname'].'/'.$file_org_path['filename'].'-100x56.jpg';
                cmst_generate_thumb($data->pic_org_path,$pic_thumb_path,100,56);

                $data->pic_lrg_url = $file_org_url['dirname'].'/'.$file_org_url['filename'].'-700x394.jpg';
                $data->pic_lrg_path = $lrg_img_path;

                $data->pic_mid_url = $file_org_url['dirname'].'/'.$file_org_url['filename'].'-500x281.jpg';
                $data->pic_mid_path = $mid_img_path;

                $data->pic_sml_url = $file_org_url['dirname'].'/'.$file_org_url['filename'].'-240x135.jpg';
                $data->pic_sml_path = $sml_img_path;

                $data->pic_pre_url = $file_org_url['dirname'].'/'.$file_org_url['filename'].'-150x150.jpg';
                $data->pic_pre_path = $pic_pre_path;

                $data->pic_thumb_url = $file_org_url['dirname'].'/'.$file_org_url['filename'].'-100x56.jpg';
                $data->pic_thumb_path = $pic_thumb_path;
        }
        
        return $data;
}
add_action( 'bp_album_data_before_save','cmst_generate_thumb',10,1);


We hooked into the bp_album_data_before_save action in order to generate the thumbnail for the video just before the data is saved to the database so that we could overwrite the paths to the generated images of different sizes that get stored in the database.


File Attachment:

File Name: bp-album-0-1-9-2-1.zip
File Size: 1,206 KB
Last Edit: 5 years ago by cmstactics.
  • Page:
  • 1
Time to create page: 0.33 seconds