1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Is it possible to make this add-on?

Discussion in 'XenForo Development Discussions' started by Luxus, Aug 16, 2013.

  1. Luxus

    Luxus Well-Known Member


    class XenForo_Model_Avatar extends XenForo_Model
    	 * List of available avatar sizes. The largest must go first.
    	 * Avatars of each size code (directory name) will be no bigger
    	 * than the given pixel amount.
    	 * @var array Format: [code] => max pixels
    	protected static $_sizes = array(
    		'l' => 192,
    		'm' => 96,
    		's' => 48
    You can directly change the l, m and s avatar sizes here. I just want to know if its possible to make an add-on for this so that you don't need to edit this file directly. I am trying to make this add-on with the help of this guide, but I see no function to extend. How to proceed?
  2. Jon W

    Jon W Well-Known Member

    Luxus likes this.
  3. Luxus

    Luxus Well-Known Member

  4. Jeremy

    Jeremy Well-Known Member

    The method Waindigo used should be able to change the size.
  5. digitalpoint

    digitalpoint Well-Known Member

    You can edit them by extending the Avatar model, use a __construct() method there that sets self::$_sizes to what you want.

    That will work for most things, but I ran into a problem in that there are 2 methods in the Avatar model that are called statically sometimes (not extended)...

    So places that use these functions, will not reflect your updated sizes...


    I ended up just needing to edit the XenForo_Model_Avatar class manually for the sizes unfortunately. Would be nice if they were settings/options or something.
    DeltaHF, Jon W, Luxus and 1 other person like this.
  6. Jon W

    Jon W Well-Known Member

    They will only not reflect the updated sizes if the XenForo_Model_Avatar object is not created before the static functions are called. Not sure if this is the case anywhere in the core XenForo code.
  7. digitalpoint

    digitalpoint Well-Known Member

    There are a few places... for example when templates call the <xen:avatar> tag... that causes the XenForo_Template_Helper_Core::helperAvatarHtml() method to be called which calls the XenForo_Model_Avatar::getSizeFromCode() method without the Avatar model being initialized upstream.
    HWS and Jon W like this.

Share This Page