Madhouse Avatar – Documentation

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">

1- Install

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 !

3.1- Helpers

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.

4- Customize

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.

A- Changelog

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

6 thoughts on “Madhouse Avatar – Documentation

  1. I can’t get this to work and I am also not receiving any help from you to make it work.
    It’s been almost a year that I have been asking for help as this tutorial does not guide one well.

  2. HI, I don’t know this part:

    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.

    What i must change?

    The rest I did correctly. Avatar is displayed but I heve problem with upload.

    Please help me 😦

  3. Hi there, my first user was named support just to make some example listings. This user has the ID = 0; when I tried to get an image associated with this ID it always showed me the avatar image. Have you checked that ID = 0 is not false? Maybe I’m wrong.

    1. Oh, that’s odd. I mean, yes the user id=0 is used for the default picture but Mysql auto_increment (ids) should not start at 0.

      It you need to, try and send us a message on the market and we’ll see if we can offer you some solutions.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s