Example #1
0
 /**
  * Adds a thumbnail image to item
  * @return unknown_type
  */
 function addfile($fieldname = 'manufacturer_image_new')
 {
     Tienda::load('TiendaImage', 'library.image');
     $upload = new TiendaImage();
     // handle upload creates upload object properties
     $upload->handleUpload($fieldname);
     // then save image to appropriate folder
     $upload->setDirectory(Tienda::getPath('manufacturers_images'));
     // Do the real upload!
     $upload->upload();
     // Thumb
     Tienda::load('TiendaHelperImage', 'helpers.image');
     $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
     $imgHelper->resizeImage($upload, 'manufacturer');
     return $upload;
 }
Example #2
0
 /**
  * Adds a thumbnail image to item
  * @return unknown_type
  */
 function addfile($fieldname = 'category_full_image_new')
 {
     Tienda::load('TiendaImage', 'library.image');
     $upload = new TiendaImage();
     // handle upload creates upload object properties
     $upload->handleUpload($fieldname);
     // then save image to appropriate folder
     $upload->setDirectory(Tienda::getPath('categories_images'));
     // do upload!
     $upload->upload();
     // Thumb
     Tienda::load('TiendaHelperImage', 'helpers.image');
     $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
     if (!$imgHelper->resizeImage($upload, 'category')) {
         JFactory::getApplication()->enqueueMessage($imgHelper->getError(), 'notice');
     }
     return $upload;
 }
Example #3
0
 /**
  * Upload via ajax through Uploadify
  * It's here because when the swf connects to the admin side, it would need to login.
  */
 function uploadifyImage()
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $product_id = JRequest::getInt('product_id', 0);
     if ($product_id) {
         Tienda::load('TiendaImage', 'library.image');
         $upload = new TiendaImage();
         // handle upload creates upload object properties
         $upload->handleUpload('Filedata');
         // then save image to appropriate folder
         $product = JTable::getInstance('Products', 'TiendaTable');
         $product->load($product_id);
         $path = $product->getImagePath();
         $upload->setDirectory($path);
         // Do the real upload!
         $success = $upload->upload();
         Tienda::load('TiendaHelperImage', 'helpers.image');
         $imgHelper = TiendaHelperBase::getInstance('Image', 'TiendaHelper');
         if (!$imgHelper->resizeImage($upload, 'product')) {
             $success = false;
         }
         if ($success) {
             // save as default?
             if (empty($product->product_full_image)) {
                 $product->product_full_image = $upload->getPhysicalName();
                 $product->save();
             }
             echo JText::_('COM_TIENDA_IMAGE_UPLOADED_CORRECTLY');
         } else {
             echo 'Error: ' . $upload->getError();
         }
     }
 }