Page 1 of 1

modify a rather large script

Posted: Tue Mar 25, 2008 6:24 am
by good945
hi all,
please bear with me that i'm a totally unpractised newbie.
i'll have a rather large phpscript that i need to modify, and i just dont know where to start.
so here we go:

i have a typo3 extension, that generates a picture gallery. i need to modify this, so that if ($width > $height) the rendered html output is different than if ($height > $width).
i just cant figure out, where the output of the $image gets defined...

the script has these sections:

Code: Select all

 
    /**
     * Generates the html-code for a thumbnail
     *
     */
    function buildLinkToThumb($path, $uid, $altTag, $linkstr = '', $text = '', $title = '', $pmkSlimbox = false)    {
 
        $conf = array();
        $conf['altText'] = $altTag;
        $conf['titleText'] = (!empty($title)) ? $title : $altTag;
        if ($pmkSlimbox) {
            $conf['stdWrap.']['typolink.']['parameter'] = $this->buildImage($path, $uid, 'detail');
            $conf['stdWrap.']['typolink.']['ATagParams'] = 'rel="lightbox[sb' . $GLOBALS['TSFE']->id . ']"';
        } else {
            $conf['stdWrap.']['typolink.']['parameter'] = $GLOBALS['TSFE']->id;
            $conf['stdWrap.']['typolink.']['additionalParams'] = $linkstr;
        }
        $conf['stdWrap.']['typolink.']['title'] = $title;
        $conf['stdWrap.']['typolink.']['useCacheHash'] = 1;
 
        $options = array('IMAGE' => $conf);
        $image = $this->buildImage($path, $uid, 'thumbnails', $options);
 
        // Render the HTML and return it:
        $html = '<div style="position: relative; display: block; overflow: hidden;">';
        // the following inserts the image
        $html .= $image;
        $html .= '</div>';
        return $html;
    }
 
and

Code: Select all

 
/**
     * function resizeImage($width, $height, $source, $target)
     * Resizes the Image to the given values
     *
     */
    function resizeImage($width, $height, $quality, $source, $target) {
        $gfxObj = t3lib_div::makeInstance("t3lib_stdgraphic");
        if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im'] == 1) {
            $stdGraphic = t3lib_div::makeInstance("t3lib_stdGraphic");
            $info = $stdGraphic->getImageDimensions($source);
            $options = array();
            $options["maxH"] = $height;
            $options["maxW"] = $width;
            $data = $stdGraphic->getImageScale($info, $width . "m", $height . "m", $options);
            $params = '-geometry ' . $data[0] . 'x' . $data[1] . '! -quality ' . $quality . ' ';
            $im = $stdGraphic->imageMagickExec($source, $target, $params);
            return $im;
        } else {
            // Get new dimensions
            list($width_orig, $height_orig) = getimagesize($source);
            if ($width && ($width_orig < $height_orig)) {
                $width = ($height / $height_orig) * $width_orig;
            } else {
                $height = ($width / $width_orig) * $height_orig;
            }
            // Resample
            $image_p = imagecreatetruecolor($width, $height);
            $image = imagecreatefromjpeg($source);
            imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig);
            // Output
            imagejpeg($image_p, $target, $quality);
        }
    }
 
i really would like to now, where i could modify this script, so that $image would render a different html if $width > $height.

the purpose is this:
the div containing the image has overflow:hidden. if the $width of an image is > than $height, the out put of the html should add a style for the image like "style="position: relative; left: -20px;".

am i wanting too much? or is this achievable?
many many thanks for any pointers!