Welcome Guest, Not a member yet? Register   Sign In
File Uploading Library. Error if image < 300 pixels?
#5

[eluser]Sinclair[/eluser]
Hi,

I'm trying to extend the Upload Library to pop up an Error when images have less than X pixels.

Code:
&lt;?PHP

class MY_Upload extends CI_Upload {
    
    var $min_width        = 0;
    var $min_height        = 0;
    
    /**
     * Set Minimum Image Height
     *
     * @access    public
     * @param    integer
     * @return    void
     */    
    function set_min_height($n)
    {
        $this->min_height = ((int) $n < 0) ? 0: (int) $n;
    }
    
    /**
     * Set Minimum Image Width
     *
     * @access    public
     * @param    integer
     * @return    void
     */    
    function set_min_width($n)
    {
        $this->min_width = ((int) $n < 0) ? 0: (int) $n;
    }
    
    /**
     * Verify that the image is within the allowed minimum width/height
     *
     * @access    public
     * @return    bool
     */    
    function is_allowed_min_dimensions()
    {
        if ( ! $this->is_image())
        {
            return TRUE;
        }

        if (function_exists('getimagesize'))
        {
            $D = @getimagesize($this->file_temp);

            if ($this->min_width > 0 AND $D['0'] > $this->min_width)
            {
                return FALSE;
            }

            if ($this->min_height > 0 AND $D['1'] > $this->min_height)
            {
                return FALSE;
            }

            return TRUE;
        }

        return TRUE;
    }
    
    
}

I have this until now. What I need to do more to get this extend working. And wich is the best way of doing this extend without broke the CI compatibility?

Best Regards,


Messages In This Thread
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-18-2010, 12:30 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-18-2010, 05:25 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-18-2010, 06:38 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-18-2010, 09:59 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-19-2010, 05:42 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-28-2010, 11:19 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-28-2010, 11:33 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-28-2010, 11:55 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-28-2010, 02:25 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 08-29-2010, 04:29 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 09-25-2010, 01:00 PM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 09-30-2010, 03:57 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 09-30-2010, 04:10 AM
File Uploading Library. Error if image < 300 pixels? - by El Forum - 07-05-2012, 04:40 AM



Theme © iAndrew 2016 - Forum software by © MyBB