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

Attachment Handler Question

Discussion in 'XenForo Development Discussions' started by neomite, Jul 20, 2012.

  1. neomite

    neomite Member

    I have a question about the attachment handler. This question is in regards to getAttachmentConstraints(), and I was wondering if it is possible to implement a public function into the attachment handler class I have created. Any detailed explanation would be appreciated as this is my first addon in XenForo, and I'm a bit rusty on php. Below is an example of how I tried to implement it, and I'm just unsure how to go about getting this to work.

    PHP:
    <?php
     
    class GFLReleases_AttachmentHandler_Releases extends XenForo_AttachmentHandler_Abstract

        public function 
    getAttachmentConstraints()
        {
            
    $params parent::getAttachmentConstraints();
            
    $options XenForo_Application::get('options');
         
            
    $params['extensions'] = preg_split('/\s+/'trim($options->GFLReleases_screenshotExtensions));
         
            return 
    $params;
        }
    }
    This is not the complete file as I already have coded all the other necessary functions. What I am trying to do with is to only allow the uploading of images through the attachment system, but only for my addon and not the entire forum. So I only want to allow certain image types to be uploaded, and I am just having some issues with getting this to work. Now the preg_split is from the actual XenForo function in the Attachment Model. I am not sure if it's the correct way of doing it or if it can even be done, but wanted to ask. I have been programming visual basic for the past year and a half so I'm very rusty with php so I may have missed something.

    Edit: After getting some rest I figured out the problem and was able to get it working.
     

Share This Page