Plugin Directory

Changeset 1210794


Ignore:
Timestamp:
08/01/2015 07:20:08 AM (11 years ago)
Author:
aghajoon
Message:

Fixed Selecting and update

Location:
bp-cover
Files:
250 added
2 edited

Legend:

Unmodified
Added
Removed
  • bp-cover/trunk/bp-cover.php

    r1209818 r1210794  
    44Plugin URI: http://webcaffe.ir
    55Description: Adds cover image in profile page and groups buddypress.
    6 Version: 2.1.0
     6Version: 2.1.1
    77Author: asghar hatampoor
    88Author URI: http://webcaffe.ir
     
    1313
    1414if ( !defined( 'BPCO_PLUGIN_VERSION' ) )
    15     define( 'BPCO_PLUGIN_VERSION', '2.1.0' );
     15    define( 'BPCO_PLUGIN_VERSION', '2.1.1' );
    1616
    1717if ( !defined( 'BPCO_PLUGIN_DIRNAME' ) )
     
    7777   $activity_id = $_POST['activity_id'];
    7878   $attachment_id = bp_activity_get_meta( $activity_id, 'bp_cover_activity', true );
    79    $fileurl = wp_get_attachment_image_src( $attachment_id );
     79   $fileurl = wp_get_attachment_image_src( $attachment_id ,'full');
    8080        update_user_meta($user_id,'bp_cover',$fileurl[0]);       
    8181        delete_user_meta($user_id,'bp_cover_position');
     
    8484add_action('wp_ajax_select_pic_for_cover', 'select_pic_for_cover');     
    8585       
    86 function button_rtmedia_for_cover($activity_id ) { 
     86function button_rtmedia_for_cover($media_id ) { 
    8787global $rtmedia_media, $rtmedia;   
    8888   $user_id=bp_loggedin_user_id(); 
     
    123123   $user_id=bp_loggedin_user_id(); 
    124124   $activity_id = $_POST['activity_id'];
    125    $attachment_id = bp_activity_get_meta( $activity_id, 'bp_cover_activity', true ); 
     125   $attachment_id = bp_activity_get_meta( $activity_id, 'bp_cover_activity', true );   
    126126        wp_delete_attachment( $attachment_id,true);
     127        delete_post_meta( $attachment_id,true);
    127128        delete_user_meta($user_id,'bp_cover');       
    128129        delete_user_meta($user_id,'bp_cover_position');         
     
    419420        $filename = $uploaddir['path']. '/' . $name;
    420421        $title = wp_unique_filename( $uploaddir['path'], $_POST['imgname'] ); 
    421         $url =  $uploaddir['url'] . '/' . $title;                       
     422        $url =  $uploaddir['url'] . '/' . $name;                       
    422423        $attachment = array(
    423424            'post_mime_type' => $type,
     
    425426            'post_title' => $title,         
    426427        );
    427  $size = @getimagesize( $filename );
    428  
    429          /* Check image size and shrink if too large */
    430          if ( $size[0] > 100 ) {
    431             $thumb = image_resize( $filename, 100, 100, true );
    432  
    433             // Check for thumbnail creation errors
    434             if ( is_wp_error( $thumb ) ) {
    435                $imgresponse[0] = "0";
    436                $imgresponse[1] = sprintf( __( 'Upload Failed! Error was: %s', 'bp-cover' ), $thumb->get_error_message() );
    437                die();
    438             }
    439  
    440             // Thumbnail is good so proceed
    441             $array_filepath = explode('/', $thumb);
    442             $image_resized = $array_filepath[count($array_filepath)-1];
    443  
    444             if ( !empty( $image_resized ) ){
    445                $imgresponse[2] = $uploaddir['url'] . '/'. $image_resized;
    446             }
    447          }
    448428        require_once( ABSPATH . 'wp-admin/includes/image.php' );
    449         $attachment_id = wp_insert_attachment($attachment,$title);         
     429        $attachment_id = wp_insert_attachment($attachment,$filename);
     430        $attach_data = wp_generate_attachment_metadata( $attachment_id, $filename );
     431        wp_update_attachment_metadata( $attachment_id,  $attach_data );
    450432        bp_activity_update_meta( $activity_id, 'bp_cover_activity', $attachment_id );
    451         update_post_meta($attachment_id, 'bp_cover_thumb', $imgresponse[2]);       
     433   
    452434}
    453435add_action("bp_cover_uploaded","bp_cover_record_activity");
  • bp-cover/trunk/readme.txt

    r1209818 r1210794  
    55Requires at least: 4.2
    66Tested up to: 4.2
    7 Stable tag: 2.1.0
     7Stable tag: 2.1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5151
    5252== Changelog ==
     53
     54= 2.1.1 =
     55- fixed  previously uploaded cover photo is broken.
    5356
    5457= 2.1.0 =
Note: See TracChangeset for help on using the changeset viewer.