public function createThumb($image, $tnumber, $twidth, $theight, $tformat, $quality = 100) { if (!($twidth && trim($twidth) != '' && is_numeric($twidth)) && !($theight && trim($theight) != '' && is_numeric($theight))) { return false; } $path = $this->_pathinfo['dirname']; $resImage = $this->_resource; // Calcul Thumb Size $values = $this->_prepareDimensions($this->_width, $this->_height, $twidth, $theight, $tformat); list($thumbX, $thumbY, $newX, $newY, $thumbWidth, $thumbHeight, $newWidth, $newHeight) = $values; // Add transparence for PNG $thumbImage = imageCreateTrueColor($thumbWidth, $thumbHeight); if ($this->_extension == 'png') { imagealphablending($thumbImage, false); } // Generate thumb ressource imagecopyresampled($thumbImage, $resImage, $thumbX, $thumbY, $newX, $newY, $thumbWidth, $thumbHeight, $newWidth, $newHeight); // Set Folder // $file_path =''; if ($tnumber == 0) { $thumbLocation = $path . '/' . $this->_pathinfo['basename']; } else { JCckDevHelper::createFolder($path . '/_thumb' . $tnumber); $thumbLocation = $path . '/_thumb' . $tnumber . '/' . $this->_pathinfo['basename']; } // Create image $this->_generateThumb($this->_extension, $thumbImage, $thumbLocation, $quality); return true; }
public function onCCK_FieldConstruct($type, &$data = array()) { if (self::$type != $type) { return; } if ($data['json']['options2']['path'][strlen($data['json']['options2']['path']) - 1] != '/') { $data['json']['options2']['path'] .= '/'; } $data['json']['options2']['path'] = trim($data['json']['options2']['path']); JCckDevHelper::createFolder(JPATH_SITE . '/' . $data['json']['options2']['path']); parent::g_onCCK_FieldConstruct($data); }
} else { //FieldX $search = '::' . $true_name . '|' . $x2k . '|' . $parent_name . '::' . '{"image_location":"' . $old_path . $file_name . '","image_title":"' . $file_title . '","image_description":"' . $file_descr . '"}' . '::/' . $true_name . '|' . $x2k . '|' . $parent_name . '::'; $replace = '::' . $true_name . '|' . $x2k . '|' . $parent_name . '::' . '{"image_location":"' . $file_location . '","image_title":"' . $file_title . '","image_description":"' . $file_descr . '"}' . '::/' . $true_name . '|' . $x2k . '|' . $parent_name . '::'; } } else { $search_v = '{"image_location":"' . $old_path . $file_name . '","image_title":"' . $file_title . '","image_description":"' . $file_descr . '"}'; $replace_v = '{"image_location":"' . $file_location . '","image_title":"' . $file_title . '","image_description":"' . $file_descr . '"}'; } } $doSave = 1; } else { $file_location = $file_path . $file_name; $location = JPATH_SITE . '/' . $file_path . $file_name; } JCckDevHelper::createFolder(JPATH_SITE . '/' . $file_path, $permissions); if (JFile::upload($tmp_name, $location)) { $thumb_count = 11; $image = new JCckDevImage($location); $src_w = $image->getWidth(); $src_h = $image->getHeight(); $value = $file_location; $fields[$name]->value = $value; $options['thumb0_process'] = $options['image_process']; $options['thumb0_width'] = $options['image_width']; $options['thumb0_height'] = $options['image_height']; for ($i = 0; $i < $thumb_count; $i++) { $format_name = 'thumb' . $i . '_process'; $width_name = 'thumb' . $i . '_width'; $height_name = 'thumb' . $i . '_height'; if ($i == 0 && $src_w == $options[$width_name] && $src_h == $optixons[$height_name]) {