2

Website: oliversdriveshaft.com

Problem: There seems to be an abundance of warning text at the top of the homepage of this site that pushes the content down inconveniently.

Methods I have tried: I tried uninstalling and reinstalling the template. I've tried actually going to the file and looking at the line the warning texts are referring to but am a little stuck on what to do after that.

This template was first installed about two years ago and the template is joomla 1.5 compatible and it is being used on Joomla version 2.5. So first of here is the warning messages that I am recieving:

Warning: Division by zero in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 95

Warning: Division by zero in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 97

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 122

Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 126

Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 127

Warning: imagecolorallocatealpha() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 128

Warning: imagefilledrectangle() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 129

Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 132

Warning: imagepng() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 135

Warning: Division by zero in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 95

Warning: Division by zero in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 97

Warning: imagecreatetruecolor(): Invalid image dimensions in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 122

Warning: imagealphablending() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 126

Warning: imagesavealpha() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 127

Warning: imagecolorallocatealpha() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 128

Warning: imagefilledrectangle() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 129

Warning: imagecopyresampled() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 132

Warning: imagepng() expects parameter 1 to be resource, boolean given in /home/oliveru0/public_html/modules/mod_bt_contentslider/classes/images.php on line 135

I'll also give you guys the code to the actual file the warning text is referring to. I've also given the specific lines mentioned. You'll find them in between the asterisks.

<?php
/**
 * @package     mod_bt_contentslider - BT ContentSlider Module
 * @version     1.1
 * @created     Oct 2011

 * @author      BowThemes
 * @email       support@bowthems.com
 * @website     http://bowthemes.com
 * @support     Forum - http://bowthemes.com/forum/
 * @copyright   Copyright (C) 2012 Bowthemes. All rights reserved.
 * @license     http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
 *
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

jimport('joomla.filesystem.file');

if (!class_exists('BTImageHelper')) {
    class BTImageHelper extends JObject {
        static function getImageCreateFunction($type) {
            switch ($type) {
                case 'jpeg':
                case 'jpg':
                    $imageCreateFunc = 'imagecreatefromjpeg';
                    break;

                case 'png':
                    $imageCreateFunc = 'imagecreatefrompng';
                    break;

                case 'bmp':
                    $imageCreateFunc = 'imagecreatefrombmp';
                    break;

                case 'gif':
                    $imageCreateFunc = 'imagecreatefromgif';
                    break;

                case 'vnd.wap.wbmp':
                    $imageCreateFunc = 'imagecreatefromwbmp';
                    break;

                case 'xbm':
                    $imageCreateFunc = 'imagecreatefromxbm';
                    break;

                default:
                    $imageCreateFunc = 'imagecreatefromjpeg';
            }

            return $imageCreateFunc;
        }

        static function getImageSaveFunction($type) {
            switch ($type) {
                case 'jpeg':
                    $imageSaveFunc = 'imagejpeg';
                    break;

                case 'png':
                    $imageSaveFunc = 'imagepng';
                    break;

                case 'bmp':
                    $imageSaveFunc = 'imagebmp';
                    break;

                case 'gif':
                    $imageSaveFunc = 'imagegif';
                    break;

                case 'vnd.wap.wbmp':
                    $imageSaveFunc = 'imagewbmp';
                    break;

                case 'xbm':
                    $imageSaveFunc = 'imagexbm';
                    break;

                default:
                    $imageSaveFunc = 'imagejpeg';
            }

            return $imageSaveFunc;
        }

        static function resize($imgSrc, $imgDest, $dWidth, $dHeight, $crop = true, $quality = 100) {
            $info = getimagesize($imgSrc, $imageinfo);
            $sWidth = $info[0];
            $sHeight = $info[1];

        **LINE 95** if ($sHeight / $sWidth > $dHeight / $dWidth) {
                $width = $sWidth;
        **LINE 97** $height = round(($dHeight * $sWidth) / $dWidth);
                $sx = 0;
                $sy = round(($sHeight - $height) / 3);
            }
            else {
                $height = $sHeight;
                $width = round(($sHeight * $dWidth) / $dHeight);
                $sx = round(($sWidth - $width) / 2);
                $sy = 0;
            }

            if (!$crop) {
                $sx = 0;
                $sy = 0;
                $width = $sWidth;
                $height = $sHeight;
            }

            //echo "$sx:$sy:$width:$height";die();

            $ext = str_replace('image/', '', $info['mime']);
            $imageCreateFunc = self::getImageCreateFunction($ext);
            $imageSaveFunc = self::getImageSaveFunction(JFile::getExt($imgDest));

            $sImage = $imageCreateFunc($imgSrc);
            **LINE 122** $dImage = imagecreatetruecolor($dWidth, $dHeight);

            // Make transparent
            if ($ext == 'png') {
                **LINE 126** imagealphablending($dImage, false);
                **LINE 127** imagesavealpha($dImage, true);
                **LINE 128** $transparent = imagecolorallocatealpha($dImage, 255, 255, 255, 127);
            **LINE 129**    imagefilledrectangle($dImage, 0, 0, $dWidth, $dHeight, $transparent);
            }

    **LINE 132**        imagecopyresampled($dImage, $sImage, 0, 0, $sx, $sy, $dWidth, $dHeight, $width, $height);

            if ($ext == 'png') {
        **LINE 135**        $imageSaveFunc($dImage, $imgDest, 9);
            }
            else if ($ext == 'gif') {
                $imageSaveFunc($dImage, $imgDest);
            }
            else {
                $imageSaveFunc($dImage, $imgDest, $quality);
            }
        }
        static function createImage($imgSrc, $imgDest, $width, $height, $crop = true, $quality = 100) {
            if (JFile::exists($imgDest)) {
                $info = getimagesize($imgDest, $imageinfo);
                // Image is created
                if (($info[0] == $width) && ($info[1] == $height)) {
                    return;
                }
            }
            self::resize($imgSrc, $imgDest, $width, $height, $crop, $quality);
        }
    }
}
?>
  • I don't see warnings? – Marko D Oct 14 '15 at 13:59
  • @MarkoD Yeah just noticed that. It's strange because when I type simply oliversdriveshaft.com in the url. I get the warnings on one of my computers. But then when I type it on the other pc, the warnings disappear. They also don't appear when I type in www.oliversdriveshaft.com – Starlight1992 Oct 14 '15 at 14:03
  • @Starlight1992 - I don't see any warnings either. Could you please copy and paste all warnings from your site in the question so we know what they are? – Lodder Oct 14 '15 at 14:13
  • @Lodder Alright, updated the post and included the warning messages that I am seeing right now – Starlight1992 Oct 14 '15 at 14:25
  • Ok all the warnings are part of a chain which are the result of the first 2 warnings. Could you try adding var_dump($sWidth); var_dump($sHeight); exit; just before the if statement on line 95 and let me know what the results are? – Lodder Oct 14 '15 at 14:29
1

I'll write this as an answer to people to see.

The errors/warnings were a chain reaction caused by $sWidth and $sHeight being 0. I simply give the OP a conditional statement for the resize function so that the code would only execute if the value was not 0, as shown below:

static function resize($imgSrc, $imgDest, $dWidth, $dHeight, $crop = true, $quality = 100) 
{                   
    if ($dWidth != 0 && $dHeight != 0)
    {
        // Code in the function to be executed
    }
    else
    {
        return;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.