- Timestamp:
- 06/02/2024 07:14:55 PM (20 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-attachment-cover-image.php
r13414 r13901 30 30 $max_upload_file_size = bp_attachments_get_max_upload_file_size( 'cover_image' ); 31 31 32 parent::__construct( array( 33 'action' => 'bp_cover_image_upload', 34 'file_input' => 'file', 35 'original_max_filesize' => $max_upload_file_size, 36 'base_dir' => bp_attachments_uploads_dir_get( 'dir' ), 37 'required_wp_files' => array( 'file', 'image' ), 38 39 // Specific errors for cover images. 40 'upload_error_strings' => array( 41 /* translators: %s: Max file size for the cover image */ 42 11 => sprintf( _x( 'That image is too big. Please upload one smaller than %s', 'cover image upload error', 'buddypress' ), size_format( $max_upload_file_size ) ), 43 44 /* translators: %s: comma separated list of file types allowed for the cover image */ 45 12 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'cover image upload error', 'buddypress' ), self::get_cover_image_types( $allowed_types ) ), 46 ), 47 ) ); 32 parent::__construct( 33 array( 34 'action' => 'bp_cover_image_upload', 35 'file_input' => 'file', 36 'original_max_filesize' => $max_upload_file_size, 37 'base_dir' => bp_attachments_uploads_dir_get( 'dir' ), 38 'required_wp_files' => array( 'file', 'image' ), 39 40 // Specific errors for cover images. 41 'upload_error_strings' => array( 42 /* translators: %s: Max file size for the cover image */ 43 11 => sprintf( _x( 'That image is too big. Please upload one smaller than %s', 'cover image upload error', 'buddypress' ), size_format( $max_upload_file_size ) ), 44 45 /* translators: %s: comma separated list of file types allowed for the cover image */ 46 12 => sprintf( _nx( 'Please upload only this file type: %s.', 'Please upload only these file types: %s.', count( $allowed_types ), 'cover image upload error', 'buddypress' ), self::get_cover_image_types( $allowed_types ) ), 47 ), 48 ) 49 ); 48 50 } 49 51 … … 83 85 $file['error'] = 11; 84 86 85 // File is of invalid type.87 // File is of invalid type. 86 88 } elseif ( isset( $file['tmp_name'] ) && isset( $file['name'] ) && ! bp_attachments_check_filetype( $file['tmp_name'], $file['name'], bp_attachments_get_allowed_mimes( 'cover_image' ) ) ) { 87 89 $file['error'] = 12; … … 138 140 3 => 180, 139 141 6 => -90, 140 8 => 90,142 8 => 90, 141 143 ); 142 144 … … 149 151 return false; 150 152 151 // Add the file to the edit arguments.153 // Add the file to the edit arguments. 152 154 } else { 153 $edit_args = array_merge( $edit_args, array( 'file' => $file, 'save' => false ) ); 155 $edit_args = array_merge( 156 $edit_args, 157 array( 158 'file' => $file, 159 'save' => false, 160 ) 161 ); 154 162 } 155 163 … … 157 165 $editor = parent::edit_image( 'cover_image', $edit_args ); 158 166 159 if ( is_wp_error( $editor ) ) {167 if ( is_wp_error( $editor ) ) { 160 168 return $editor; 161 169 } elseif ( ! is_a( $editor, 'WP_Image_Editor' ) ) { … … 173 181 * 174 182 * @param string $file The absolute path to the file. 175 * @return false|string $value The absolute path to the new file name.183 * @return false|string 176 184 */ 177 185 public function generate_filename( $file = '' ) { … … 208 216 'item_id' => $item_id, 209 217 'has_cover_image' => bp_attachments_get_user_has_cover_image( $item_id ), 210 'nonces' => array(218 'nonces' => array( 211 219 'remove' => wp_create_nonce( 'bp_delete_cover_image' ), 212 220 ), … … 226 234 'item_id' => bp_get_current_group_id(), 227 235 'has_cover_image' => bp_attachments_get_group_has_cover_image( $item_id ), 228 'nonces' => array(236 'nonces' => array( 229 237 'remove' => wp_create_nonce( 'bp_delete_cover_image' ), 230 238 ),
Note: See TracChangeset
for help on using the changeset viewer.