This is the documentation page for Madhouse Avatar, a plugin for Osclass to enable user to have a profile picture.
If you have trouble to upload an avatar on registration or on profile page. Don’t forget that you need the enctype attribute (enctype=”multipart/form-data”) on your form te be able to upload image.
<form action="<?php echo osc_base_url(true); ?>" method="post" enctype="multipart/form-data">
You probably got your plugin on the market, therefore, just click install and you’re done.
In the case you have the plugin packaged as a zip, just follow our tutorial on how to install manually a plugin on Osclass.
2- Integrate with your theme
If your using Bender, well, 99% of the work is already done.
2.1- Display upload form
Once installed, it should already show on register and user account page and let your users upload a profile picture.
If it does not show, make sure your theme has a user_register_form and user_profile_form in user-register.php and user-profile.php. If missing, add them with these hooks
For register form:
<?php osc_run_hook("user_register_form"); ?>
For profile form:
<?php osc_run_hook("user_profile_form", osc_user()); ?>
2.2- Display profile picture for your user
Just go to your user-public-profile.php and replace the image (around line 60) by a call to Madhouse Avatar helper.
<img src="<?php echo mdh_avatar_thumbnail_url(osc_user_id()); ?>" />
And… your done !
There’s only 4 helpers that you can use in your theme.
mdh_avatar_nav_url($userId) – Returns the URL to the profile picture in ‘nav’ size.
mdh_avatar_thumbnail_url($userId) – Returns the URL to the profile picture in ‘thumbnail’ size.
mdh_avatar_preview_url($userId) – Returns the URL to the profile picture in ‘preview’ size.
mdh_avatar_normal_url($userId) – Returns the URL to the profile picture in ‘normal’ size.
3.2- Helpers, how to use them
3.2.1- On item page
<img src="<?php echo mdh_avatar_preview_url(osc_item_user_id()); ?>" />
3.2.2- On user public profile
<img src="<?php echo mdh_avatar_preview_url(osc_user_id()); ?>" />
3.2.2- On user profile
<img src="<?php echo mdh_avatar_preview_url(osc_logged_user_id()); ?>" />
3.3- There’s two things to note
- the URL of the profile picture of the current logged in user is returned if the first parameter is omitted;
- the URL to the default profile picture is returned if the user does not have a profile picture.
You can completely customize the upload form that shows at registration and in the edit of a user profile: here’s a tutorial about how you can customize it within your own theme.
1.42.0 / Janvier 2016 Important fix for the location of each profile picture. He is now on the right folder. Now based on the resourceId Before this update the folder name was based on the userId [*] The plugin is now in french (thanks to Romain of Madhouse Team) [i] Fix typo on `processedResrouces -> processedResources` [*] Refactor JS on regenerate.php (less specific) [*] New settings page with icons 1.41 / September 2015 [!] Fix a bug for the position of the form on the register form 1.40 / February 2015 First public release ---