Coder Social home page Coder Social logo

thanhtung2693 / profilepicture Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mosets/profilepicture

0.0 2.0 0.0 291 KB

A light and simple Joomla plugin for creating profile picture for your users.

Home Page: http://extensions.joomla.org/extension/profile-picture

Shell 13.97% PHP 85.34% HTML 0.69%

profilepicture's Introduction

Profile Picture

Profile Picture is a Joomla package that enables your users to upload their profile picture to your Joomla website. It includes the following extensions:

  • Profile Picture User Plugin - This is the main plugin that allows your users to upload, remove and change their profile picture. Administrator too can manage these pictures in Joomla's Users Manager.

  • Profile Picture Library - Profile Picture library provides API for third party developers to access and display users' profile picture.

How to use

It's super easy to use profile picture in your existing codes. Make sure to load the ProfilePicture library first:

jimport('profilepicture.profilepicture');

Create a ProfilePicture instance and pass the user ID:

$profilepicture = new ProfilePicture(1);

Use the toHTML method to output the IMG element for the user's profile picture. If profile picture for the user does not exists, the filler image will be shown:

echo $profilepicture->toHTML();

There are 3 sizes defined as constants in Profile Picture:

  • PROFILEPICTURE_SIZE_ORIGINAL
  • PROFILEPICTURE_SIZE_50
  • PROFILEPICTURE_SIZE_200

By default, toHTML will output using PROFILEPICTURE_SIZE_200. You may specify the profile picture size by passing the size constant to toHTML method:

echo $profilepicture->toHTML(PROFILEPICTURE_SIZE_50);

The toHTML method also allows you to specify the ALT attribute and additional attributes for the IMG element:

echo $profilepicture->toHTML(PROFILEPICTURE_SIZE_50, 'Lee', ['class' => 'profile', 'id' => 'lee-profile-picture']);

Here's a full example that displays the currently logged in user's profile picture.

jimport('profilepicture.profilepicture');

$user = JFactory::getUser();

$profilepicture = new ProfilePicture($user->get('id'));

echo $profilepicture->toHTML(PROFILEPICTURE_SIZE_200, $user->get('name'));

The library also includes the following methods: getFillerURL, getURL, getPath and exists. You can pass the size constant to refer to a specific size, otherwise it will defaults to PROFILEPICTURE_SIZE_200.

Requirements

Joomla 3.4 and GD image library support for PHP.

Author

CY Lee

Copyright and license

Copyright (c) 2012-present Mosets Consulting

Licensed under the MIT License.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

profilepicture's People

Contributors

cheryeong avatar g3z avatar

Watchers

James Cloos avatar Ted avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.