Modify the uploaded profile picture in Discuz to a non-Flash version

Discuz! profile pictures are always uploaded in Flash, and you can't change the language pack or style. Here's how to change them to HTML5:

  1. Add the relevant language to the language pack: Add the following to source/language/home/lang_template.php
'back_file_selection' => 'Return to select again', 'upload_succeed' => 'Upload successful!', 'three_avatars' => 'These are the three sizes of your avatar',
  1. Modify the uploaded template: template/default/home/spacecp_avatar.htm
  2. Modify file processing script

Modified file download:avatar_160104a

Upload profile picture process:

Existing processes

1) Profile Picture Editing Webpage
Discuz 上传头像修改成非flash版本 - - Jake blog
The profile picture editing webpage was obtained from the following request:

GET /home.php?mod=spacecp&ac=avatar

The script file that handles the requests is source/include/spacecp/spacecp_avatar.php, while the webpage format is defined in the template file template/default/home/spacecp_avatar.htm. This webpage contains a Flash animation uc_server/images/camera.swf, providing avatar editing client functionality.

GET /uc_server/images/camera.swf?inajax=1&appid=1&input=201eHYPCqwF…

2) Upload profile picture
Discuz 上传头像修改成非flash版本 - 183912tlwdaflwubmokaab - Jake blog
The selection and uploading of avatar files are provided by the Flash animation camera.swf. It sends the following request to the server, which includes the content of the avatar file:

POST /uc_server/index.php?m=user&inajax=1&a=uploadavatar&appid=1&input=201eHYPCqwF…

This request is handled by the function `onuploadavatar` in the script file `uc_server/control/user.php`. It saves the file on the server and sends the file's path back to the Flash animation `camera.swf`.

3) Crop the portrait
Discuz 上传头像修改成非flash版本 - 184609m6uu6zjl1k61iij8 - Jake blog
The image scaling and cropping functionality is provided by the Flash animation camera.swf. After clicking the OK button, the Flash animation sends the following request to the server:

POST /uc_server/index.php?m=user&inajax=1&a=rectavatar&appid=1&input=201eHYPCqwF…

urlReaderTS=1451947309935&avatar1=FFD8FFE000104A4649460001…

The request contained profile pictures in three sizes (small, medium, and large) after cropping. The script file uc_server/control/user.php on the server processed this request and saved the uploaded profile pictures.

4) Display avatar
Discuz 上传头像修改成非flash版本 - 184720okyz95bk455q9kqe - Jake blog
The display of the three avatar sizes is also provided by the Flash animation camera.swf.

New process
The revised profile picture editing process is as follows:

1) Profile Picture Editing Webpage
Discuz 上传头像修改成非flash版本 - 202940ubkowdw9z92o9rfw - Jake blog
The profile picture editing webpage was obtained from the following request:

GET /home.php?mod=spacecp&ac=avatar

The script file that handles the requests is source/include/spacecp/spacecp_avatar.php, while the webpage format is defined in the template file template/default/home/spacecp_avatar.htm. This webpage contains several canvases and provides avatar editing client functionality.

GET /uc_server/images/camera.swf?inajax=1&appid=1&input=201eHYPCqwF…

2) Upload profile picture
Discuz 上传头像修改成非flash版本 - 203059wml9vm4hlqmktwgk - Jake blog
The selection and uploading of profile picture files are provided by the `file` element in the HTML. It sends the following request to the server, which includes the content of the profile picture file:

POST /uc_server/index.php?m=user&inajax=1&a=uploadavatar&appid=1&input=201eHYPCqwF…

This request is handled by the function `onuploadavatar` in the script file `uc_server/control/user.php`. It saves the file on the server and sends the file's path back to the client.

3) Crop the portrait
Discuz 上传头像修改成非flash版本 - 203157zz8aat22tl92u2ju - Jake blog
Image scaling and cropping functionality is provided by a combination of the canvas and drag-and-drop widgets in jQuery UI. After clicking the OK button, the client sends the following request to the server:

POST /uc_server/index.php?m=user&inajax=1&a=rectavatar&appid=1&input=201eHYPCqwF…

——WebKitFormBoundary7I7NlBxh4ycJkBD8 Content-Disposition: form-data; name=”avatar1″ /9j/4AAQSkZJRgABAQAAAQABAAD…

The request contained profile pictures in three sizes (small, medium, and large) after cropping. The script file uc_server/control/user.php on the server processed this request and saved the uploaded profile pictures.

4) Display avatar
Discuz 上传头像修改成非flash版本 - - Jake blog
The display of the three avatar sizes is also provided by the canvas.

Original article from: Beyond.net

This siteOriginal articleAll follow "Attribution-NonCommercial-ShareAlike 4.0 License (CC BY-NC-SA 4.0)Please retain the following annotations when sharing or adapting:

Original author:Jake Tao,source:"Change the uploaded profile picture to a non-Flash version in Discuz"

188
0 0 188

Further Reading

Post a reply

Log inYou can only comment after that.
Share this page
Back to top