コード例 #1
0
ファイル: zoo.php プロジェクト: bizanto/Hooked
 public static function image($image, $width = null, $height = null)
 {
     $resized_image = ZooHelper::resizeImage(JPATH_ROOT . DS . $image, $width, $height);
     $inner_path = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $resized_image)), '/');
     $path = JPATH_ROOT . '/' . $inner_path;
     if (is_file($path) && ($size = getimagesize($path))) {
         $info['path'] = $path;
         $info['src'] = JURI::root() . $inner_path;
         $info['mime'] = $size['mime'];
         $info['width'] = $size[0];
         $info['height'] = $size[1];
         $info['width_height'] = sprintf('width="%d" height="%d"', $info['width'], $info['height']);
         return $info;
     }
     return null;
 }
コード例 #2
0
ファイル: image.php プロジェクト: bizanto/Hooked
 public function renderSubmission($params = array())
 {
     // load js
     JHTML::script('image.js', 'administrator/components/com_zoo/elements/image/assets/js/');
     // init vars
     $image = $this->_data->get('file');
     // is uploaded file
     $image = is_array($image) ? '' : $image;
     // get params
     $params = new YArray($params);
     $trusted_mode = $params->get('trusted_mode');
     // build image select
     $lists = array();
     if ($trusted_mode) {
         $options = array(JHTML::_('select.option', '', '- ' . JText::_('Select Image') . ' -'));
         if (!empty($image) && !$this->_inUploadPath($image)) {
             $options[] = JHTML::_('select.option', $image, '- ' . JText::_('No Change') . ' -');
         }
         $img_ext = str_replace(',', '|', trim(JComponentHelper::getParams('com_media')->get('image_extensions'), ','));
         foreach (YFile::readDirectoryFiles(JPATH_ROOT . '/' . $this->_getUploadImagePath() . '/', $this->_getUploadImagePath() . '/', '/\\.(' . $img_ext . ')$/i', false) as $file) {
             $options[] = JHTML::_('select.option', $file, basename($file));
         }
         $lists['image_select'] = JHTML::_('select.genericlist', $options, 'elements[' . $this->identifier . '][image]', 'class="image"', 'value', 'text', $image);
     } else {
         if (!empty($image)) {
             $image = ZooHelper::resizeImage(JPATH_ROOT . DS . $image, 0, 0);
             $image = trim(str_replace('\\', '/', preg_replace('/^' . preg_quote(JPATH_ROOT, '/') . '/i', '', $image)), '/');
         }
     }
     if (!empty($image)) {
         $image = JURI::root() . $image;
     }
     if ($layout = $this->getLayout('submission.php')) {
         return self::renderLayout($layout, array('element' => $this->identifier, 'lists' => $lists, 'image' => $image));
     }
 }
コード例 #3
0
ファイル: gallery.php プロジェクト: bizanto/Hooked
 protected function _getThumbnails($params)
 {
     $thumbs = array();
     $width = $params->get('width');
     $height = $params->get('height');
     $resize = $params->get('resize', 1);
     $title = $this->_data->get('title', '');
     $files = JFolder::files($this->_path, '.', false, true, array('.svn', 'CVS', '.DS_Store'));
     $files = array_filter($files, create_function('$file', 'return preg_match("#(\\.bmp|\\.gif|\\.jpg|\\.jpeg|\\.png)$#i", $file);'));
     // set default thumbnail size, if incorrect sizes defined
     $width = intval($width);
     $height = intval($height);
     if ($width < 1 && $height < 1) {
         $width = 100;
         $height = null;
     }
     foreach ($files as $file) {
         $filename = basename($file);
         $thumb = ZooHelper::resizeImage($file, $width, $height);
         // if thumbnail exists, add it to return value
         if (is_file($thumb)) {
             // set image name or title if exsist
             if ($title != '') {
                 $name = $title;
             } else {
                 $name = JFile::stripExt($filename);
                 $name = JString::str_ireplace('_', ' ', $name);
                 $name = JString::ucwords($name);
             }
             // get image info
             list($thumb_width, $thumb_height) = @getimagesize($thumb);
             $thumbs[] = array('name' => $name, 'filename' => $filename, 'img' => $this->_uri . $this->_getRelativePath($file), 'img_file' => $file, 'thumb' => $this->_uri . $this->_getRelativePath($thumb), 'thumb_width' => $thumb_width, 'thumb_height' => $thumb_height);
         }
     }
     return $thumbs;
 }