Advertisement:

Author Topic: [Updated Plugin] Upload Profile Picture  (Read 147138 times)

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
[Updated Plugin] Upload Profile Picture
« on: February 13, 2012, 08:41:05 am »
Updated 12/31/2012

The updates include:
  • Fixed size issue preventing pictures from showing in Internet Explorer
  • Ability to delete a photo and revert back to default "no-photo"
  • Default photo is now displayed in the Dashboard on the page "My account" (assuming you've placed the correct code on that page as per plugin instructions)



Hi all,

Here's a simple plugin that will upload a picture and display it on the profile page, or where ever you'd like.

1) Download and install the plugin

2) Place this code on the theme page, user-profile.php - make sure this code is place OUTSIDE of the existing form on that page - this function will allow users to upload their profile picture
Code: [Select]
<?php profile_picture_upload(); ?>
3) Place this code on pages you wish to display the profile picture, including user-public-profile.php and item.php
Code: [Select]
<?php profile_picture_show(); ?>
That's it.

This is a no-frills plugin, meaning it doesn't do anything but upload and display. The uploaded files are NOT re-sized, but are limited to file size (set at 500kb initially, you can change that).

You'll probably want to edit the file index.php within the plugin folder. There are several fields you can edit, including the display width of the picture.

How To Use
To upload a picture, you just need to login to your account, then from the account manager, click on My account.
« Last Edit: January 01, 2013, 02:47:15 am by Jesse »

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: [New Plugin] Upload Profile Picture
« Reply #1 on: February 13, 2012, 08:52:11 am »
Hi Jesse,

This plugin works very well for the most part. I did how ever find a small bug. When ever a user logs out it shows the first users profile picture. It will show the second users profile picture if he logs in but once he logs out it goes back to the first users profile picture. Also I placed the code in the header.php file of my theme.

Jay

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #2 on: February 13, 2012, 08:57:26 am »
Hi Jay,

You mention about a "first" and "second" user profile picture. There should only be one. Are you saying if the user has uploaded more than one photo, it reverts back to showing the "first uploaded picture"?

Since additional uploaded photos are saved with the same name, a simple page "reload" will fix issues if they're related to that. But there certainly could be a bug! I'm anxious to hear more.  :)

And this was ONLY tested on the file user-public-profile.php, as it's the only one that should matter, at least for the current plugin function.
« Last Edit: February 13, 2012, 08:58:57 am by Jesse »

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: [New Plugin] Upload Profile Picture
« Reply #3 on: February 13, 2012, 09:06:08 am »
Hi Jay,

You mention about a "first" and "second" user profile picture. There should only be one. Are you saying if the user has uploaded more than one photo, it reverts back to showing the "first uploaded picture"?

It does only allow the user to upload one picture and that part is working right. It is when a second user logs in and uploads a profile picture. I does work right on the profile page the only time it has an issue is in the header and I am on the home page.

I have found that it also works on the item.php file.

Thanks

Jay

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #4 on: February 13, 2012, 09:25:02 am »
Hi Jay,

Ok, thank you for clarifying that for me!

There are a few things that come to mind that might keep it from working in the header. For one thing, the plugin uses osc_item_user_id(), which may not work on all pages. To be honest, I didn't have any intention of it being used "all over" the site... just on the profile page, and perhaps Item pages.

One other thing, the plugin uses <meta http-equiv="refresh" content="0; ,URL='.$url.'"> to refresh the page after the picture has been uploaded to try and refresh the display. This has worked pretty well in testing, but may cause issues elsewhere.

ingo

  • Full Member
  • ***
  • Posts: 216
Re: [New Plugin] Upload Profile Picture
« Reply #5 on: February 13, 2012, 10:06:10 am »
Hi Jesse,

great hit again,

is it possible to upload user picture in user- profile.php  > update your profil > and show in public-profile  or item.php

to have profil updates on one page

THX for This Plugin I will use it  :)

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #6 on: February 13, 2012, 10:20:33 am »
Hi Ingo,

It is possible to use it on the user-profile.php page. But some modifications to the plugin would be needed.

Right now, the plugin uses the function osc_item_user_id() to get the ID number for the Public Profile page. That function doesn't work on the user-profile.php page, so you'd have to use osc_logged_user_id() instead to set $user_id in the plugin.

There are a few more modifications that would be required as well.

I will look into making this better. I know it would be nice to be able to set the profile picture from the user-profile page. What I can do is, make the current profile_picture() function work on the user-profile page. Then, for showing the picture on the actual Public Profile page (or anywhere else on the site), I can have a separate function just for that (without an upload form). I probably should have done this originally, but the way I did it seemed like a good idea at the time.

Give me some time and I'll get it done!  :D

ingo

  • Full Member
  • ***
  • Posts: 216
Re: [New Plugin] Upload Profile Picture
« Reply #7 on: February 13, 2012, 10:50:49 am »
great, no hurry, when time allows to you and  when easy possible!
and don't forget to sleep from time to time  :)

Thanks again for this great extension

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #8 on: February 13, 2012, 12:51:24 pm »
Ok, I've uploaded the latest version 1.1,  download from my first post.

In this version, there are two functions as outlined in my first post. One function will display both the upload form and the profile picture.

The second function will simply display only the profile picture. I've also added a "no profile picture" picture as suggested in an earlier topic that will be shown when the user hasn't uploaded a profile picture.


Test away and please continue to report any bugs!  :)

seven

  • Jr. Member
  • **
  • Posts: 73
Re: [New Plugin] Upload Profile Picture
« Reply #9 on: February 13, 2012, 03:23:39 pm »
Hi Jesse,

I can just say great great great work :)  !!


Wish you can continue working like that.


kind regards

« Last Edit: February 13, 2012, 03:31:12 pm by seven »

Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #10 on: February 13, 2012, 03:49:08 pm »
Thanks Seven! I do my best. There are a lot of plugins that I want to at least get started. I figure if I can at least get these things working, others can come along and customize them and make them better. My next plugin is already underway (Print Ad - this plugin will pop-up a printer-friendly version of the item/ad).


Future update: I'll eventually be adding an option to this plugin for "company" users to upload a larger size logo/banner (like 330px wide and 150px high). There will probably be an additional function added for that. I'll see. Ingo had this good suggestion.  :)
« Last Edit: February 13, 2012, 04:03:35 pm by Jesse »

seven

  • Jr. Member
  • **
  • Posts: 73
Re: [New Plugin] Upload Profile Picture
« Reply #11 on: February 13, 2012, 04:15:17 pm »
Nice :)

This one (print) is needed to :) !


Jesse, plugin works fine but I don't want that every user puts is profile picture in it. Only users that I decide (for exemple company logo as profile picture)
I've tried to ad the function into the oc-admin user section.
It works to add the picture if im loged in on front side with the user profile I wan't to change... But normaly I don't have the password from user to log in so that I only can change for user I know the password..

Take a look at the attached file.. It's more easy to understand what I m trying to write...


Jesse

  • Hero Member
  • *****
  • Posts: 631
  • Out of my mind, back in 5 minutes
Re: [New Plugin] Upload Profile Picture
« Reply #12 on: February 13, 2012, 04:34:38 pm »
Hi Seven,

The plugin is setup right now to allow all users to choose their own profile picture on the front-end. The plugin gets the user's logged-in user ID from the array generated by OSClass. If you try to use this plugin elsewhere (like in the Admin section), the plugin wont know what user ID you're trying to use.

It's certainly possible to adapt this plugin to the back-end so that only you can choose the profile picture for just the users you choose (I think that's what you're asking to do?). Of course, that would require more work.  :) And being that I can't see many people wanting this back-end feature (if you're going to have a profile picture, it's generally accepted that the user can choose it for themselves), I can't really take the time right now to customize it for you. But I can certainly give some ideas as how to do it if you'd like? Basically, you'll need to populate a drop-down box with all user ID's/Usernames. You can then manually select the user/userID you wish to edit. That will then allow the plugin to work as normal.

seven

  • Jr. Member
  • **
  • Posts: 73
Re: [New Plugin] Upload Profile Picture
« Reply #13 on: February 13, 2012, 04:57:32 pm »
thanks for the reply. :)




seven

  • Jr. Member
  • **
  • Posts: 73
Re: [New Plugin] Upload Profile Picture
« Reply #14 on: February 13, 2012, 07:46:14 pm »
Hi Jesse,

I've done my modification so that I can change in admin site the picture for the users I want a picture shown...


I'll write it here if someone needs to do it.  (Surely not the best way to do it.. but it works)

1step:  install the orginal plugin (from Jesse)
2step:  rename (or delete)  the  'no_picture.jpg' in the plugin directory
3step:  in the plugin directory edit the file index.php and search line 61,
              replace           $user_id =.....         with              $user_id =   osc_user_id ();
4step:  delete line         73                    if( osc_is_web_user_logged_in() ) {     
            and delete line   89                    } //if logged-in
5step:  edit     item.php (in folder of your theme)   
             and write       <?php profile_picture_show(); ?>     (Like asked in the original plugin)
6step:  in the folded   ?example.com?/oc-admin/themes/modern/users   
            edit the file     frm.php
            and place after the  text     </form>      this text:         <?php profile_picture_upload(); ?>


EVERYTIME BACKUP YOUR ORIGINAL FILES BEFORE CHANGING THEM

(THIS IS NOT THE BEST WAY TO DO IT, IF YOU DON'T NEED IT, THAN LET THE PLUGIN FROM JESSE IN ORIGINAL - IS BETTER FOR FUTURE UPDATES)


kind regards

« Last Edit: February 14, 2012, 12:30:29 am by seven »