src/Controller/Base.php
protected function serveBadSrc(array $params)
    {
        $width  = isset($params['width']) ? $params['width'] : 100;
        $height = isset($params['height']) ? $params['height'] : 100;
        $sError = isset($params['error']) ? $params['error'] : '';

        //  Make sure this doesn't get cached
        $this->unsetCacheHeaders();

        // --------------------------------------------------------------------------

        //  Create the icon
        if ($this->isRetina) {
            $icon = @imagecreatefrompng($this->cdnRoot . '_resources/img/fail@2x.png');
        } else {
            $icon = @imagecreatefrompng($this->cdnRoot . '_resources/img/fail.png');
        }
        $iconW = imagesx($icon);
        $iconH = imagesy($icon);

        // --------------------------------------------------------------------------

        //  Create the background
        $bg    = imagecreatetruecolor($width, $height);
        $white = imagecolorallocate($bg, 255, 255, 255);
        imagefill($bg, 0, 0, $white);

        // --------------------------------------------------------------------------

        //  Merge the two
        $centerX = ($width / 2) - ($iconW / 2);
        $centerY = ($height / 2) - ($iconH / 2);
        imagecopymerge($bg, $icon, $centerX, $centerY, 0, 0, $iconW, $iconH, 100);

        // --------------------------------------------------------------------------

        //  Write the error on the bottom
        if (!empty($sError)) {
            $textcolor = imagecolorallocate($bg, 0, 0, 0);
            imagestring($bg, 1, 5, $height - 15, 'ERROR: ' . $sError, $textcolor);
        }

        // --------------------------------------------------------------------------

        //  Output to browser
        $oInput = Factory::service('Input');
        header('Content-Type: image/png', true);
        header($oInput->server('SERVER_PROTOCOL') . ' 400 Bad Request', true, 400);
        imagepng($bg);

        // --------------------------------------------------------------------------

        //  Destroy the images
        imagedestroy($icon);
        imagedestroy($bg);

        // --------------------------------------------------------------------------

        /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/

        exit(0);
    }
protected function serveBadSrc(array $params)
    {
        $width  = isset($params['width']) ? $params['width'] : 100;
        $height = isset($params['height']) ? $params['height'] : 100;
        $sError = isset($params['error']) ? $params['error'] : '';

        //  Make sure this doesn't get cached
        $this->unsetCacheHeaders();

        // --------------------------------------------------------------------------

        //  Create the icon
        if ($this->isRetina) {
            $icon = @imagecreatefrompng($this->cdnRoot . '_resources/img/fail@2x.png');
        } else {
            $icon = @imagecreatefrompng($this->cdnRoot . '_resources/img/fail.png');
        }
        $iconW = imagesx($icon);
        $iconH = imagesy($icon);

        // --------------------------------------------------------------------------

        //  Create the background
        $bg    = imagecreatetruecolor($width, $height);
        $white = imagecolorallocate($bg, 255, 255, 255);
        imagefill($bg, 0, 0, $white);

        // --------------------------------------------------------------------------

        //  Merge the two
        $centerX = ($width / 2) - ($iconW / 2);
        $centerY = ($height / 2) - ($iconH / 2);
        imagecopymerge($bg, $icon, $centerX, $centerY, 0, 0, $iconW, $iconH, 100);

        // --------------------------------------------------------------------------

        //  Write the error on the bottom
        if (!empty($sError)) {
            $textcolor = imagecolorallocate($bg, 0, 0, 0);
            imagestring($bg, 1, 5, $height - 15, 'ERROR: ' . $sError, $textcolor);
        }

        // --------------------------------------------------------------------------

        //  Output to browser
        $oInput = Factory::service('Input');
        header('Content-Type: image/png', true);
        header($oInput->server('SERVER_PROTOCOL') . ' 400 Bad Request', true, 400);
        imagepng($bg);

        // --------------------------------------------------------------------------

        //  Destroy the images
        imagedestroy($icon);
        imagedestroy($bg);

        // --------------------------------------------------------------------------

        /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/

        exit(0);
    }
protected function serveBadSrc ( array $ params ) { $ width = isset ( $ params [ 'width' ] ) ? $ params [ 'width' ] : 100 ; $ height = isset ( $ params [ 'height' ] ) ? $ params [ 'height' ] : 100 ; $ sError = isset ( $ params [ 'error' ] ) ? $ params [ 'error' ] : '' ; //  Make sure this doesn't get cached $ this -> unsetCacheHeaders ( ) ; // -------------------------------------------------------------------------- //  Create the icon if ( $ this -> isRetina ) { $ icon = @ imagecreatefrompng ( $ this -> cdnRoot . '_resources/img/fail@2x.png' ) ; } else { $ icon = @ imagecreatefrompng ( $ this -> cdnRoot . '_resources/img/fail.png' ) ; } $ iconW = imagesx ( $ icon ) ; $ iconH = imagesy ( $ icon ) ; // -------------------------------------------------------------------------- //  Create the background $ bg = imagecreatetruecolor ( $ width , $ height ) ; $ white = imagecolorallocate ( $ bg , 255 , 255 , 255 ) ; imagefill ( $ bg , 0 , 0 , $ white ) ; // -------------------------------------------------------------------------- //  Merge the two $ centerX = ( $ width / 2 ) - ( $ iconW / 2 ) ; $ centerY = ( $ height / 2 ) - ( $ iconH / 2 ) ; imagecopymerge ( $ bg , $ icon , $ centerX , $ centerY , 0 , 0 , $ iconW , $ iconH , 100 ) ; // -------------------------------------------------------------------------- //  Write the error on the bottom if ( ! empty ( $ sError ) ) { $ textcolor = imagecolorallocate ( $ bg , 0 , 0 , 0 ) ; imagestring ( $ bg , 1 , 5 , $ height - 15 , 'ERROR: ' . $ sError , $ textcolor ) ; } // -------------------------------------------------------------------------- //  Output to browser $ oInput = Factory :: service ( 'Input' ) ; header ( 'Content-Type: image/png' , true ) ; header ( $ oInput -> server ( 'SERVER_PROTOCOL' ) . ' 400 Bad Request' , true , 400 ) ; imagepng ( $ bg ) ; // -------------------------------------------------------------------------- //  Destroy the images imagedestroy ( $ icon ) ; imagedestroy ( $ bg ) ; // -------------------------------------------------------------------------- /**
         * Kill script, th, th, that's all folks.
         * Stop the output class from hijacking our headers and
         * setting an incorrect Content-Type
         **/ exit ( 0 ) ; }
Serve up the "fail whale" graphic
@return void
Serve up the fail whale graphic