<?php if (!empty($this->itemDetail['images'])) { ?> <div class=" "> <div class="text-info"> <?php echo JText::_('COM_Q2C_UNCHECK_TO_REMOVE_EXISTING_IMAGE'); ?> </div> <div class="row-fluid"><!-- wrapper for images--> <ul class="thumbnails qtc_ForLiStyle" id="qtc_nev"> <?php $images = json_decode($this->itemDetail['images'], true); require_once JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'media.php'; //create object of media helper class $media = new qtc_mediaHelper(); foreach ($images as $key => $img) { if (!empty($img)) { $originalImg = $img; $file_name_without_extension = $media->get_media_file_name_without_extension($img); $media_extension = $media->get_media_extension($img); $img = $comquick2cartHelper->isValidImg($file_name_without_extension . '_S.' . $media_extension); if (empty($img)) { $img = JUri::root() . 'components' . DS . 'com_quick2cart' . DS . 'images' . DS . 'default_product.jpg'; } ?> <li> <label class="checkbox"> <input class="qtcmarginLeft1px" type="checkbox" name="qtc_prodImg[<?php echo $key; ?>
"> <!-- Show main image--> <div class="row-fluid"> <div class='span12'> <?php $images = !empty($this->itemdetail->images) ? json_decode($this->itemdetail->images, true) : ''; $img = JUri::base() . 'components' . DS . 'com_quick2cart' . DS . 'assets' . DS . 'images' . DS . 'default_product.jpg'; if (!empty($images)) { // Get first key $firstKey = 0; foreach ($images as $key => $img) { $firstKey = $key; break; } require_once JPATH_SITE . DS . 'components' . DS . 'com_quick2cart' . DS . 'helpers' . DS . 'media.php'; $media = new qtc_mediaHelper(); $file_name_without_extension = $media->get_media_file_name_without_extension($images[$firstKey]); $media_extension = $media->get_media_extension($images[$firstKey]); $img = $comquick2cartHelper->isValidImg($file_name_without_extension . '_L.' . $media_extension); if (empty($img)) { $img = JUri::base() . 'components' . DS . 'com_quick2cart' . DS . 'assets' . DS . 'images' . DS . 'default_product.jpg'; } } if (!empty($images)) { ?> <a href="<?php echo $img; ?> " class="swipebox" title="<?php echo $this->itemdetail->name; ?>
/** * for image upload * * @param STRING $file_field file_field. * @param STRING $img_dimensions_config img_dimensions_config. * @param INTEGER $upload_orig upload_orig. * * @return STRING */ public function imageupload($file_field, $img_dimensions_config, $upload_orig = '1') { require_once JPATH_SITE . '/components/com_quick2cart/helpers/media.php'; // Create object of media helper class $media = new qtc_mediaHelper(); $params = JComponentHelper::getParams('com_quick2cart'); // Get uploaded media details // Orginal file name $file_name = $_FILES[$file_field]['name']; // Convert name to lowercase $file_name = strtolower($_FILES[$file_field]['name']); // Replace "spaces" with "_" in filename $file_name = preg_replace('/\\s/', '_', $file_name); $file_type = $_FILES[$file_field]['type']; $file_tmp_name = $_FILES[$file_field]['tmp_name']; $file_size = $_FILES[$file_field]['size']; $file_error = $_FILES[$file_field]['error']; // Set error flag, if any error occurs set this to 1 $error_flag = 0; // Check for max media size allowed for upload $max_size_exceed = $media->check_max_size($file_size); if ($max_size_exceed) { $errorList[] = JText::_('FILE_BIG') . " " . $params->get('max_size') . "KB<br>"; $error_flag = 1; } if (!$error_flag) { // Detect file type // Detect media group type image/video/flash $media_type_group = $media->check_media_type_group($file_type); if (!$media_type_group['allowed']) { $errorList[] = JText::_('FILE_ALLOW'); $error_flag = 1; } if (!$error_flag) { $media_extension = $media->get_media_extension($file_name); // Upload original img $file_name_without_extension = $media->get_media_file_name_without_extension($file_name); $timestamp = time(); $original_file_name_without_extension = $file_name_without_extension . '_' . $timestamp; $original_file_name = $original_file_name_without_extension . '.' . $media_extension; // Always use constants when making file paths, to avoid the possibilty of remote file inclusion $fullPath = JPATH_SITE . DS . 'images' . DS . 'quick2cart' . DS; $relPath = 'images' . DS . 'quick2cart' . DS; // If folder is not present create it if (!JFolder::exists(JPATH_SITE . DS . 'images' . DS . 'quick2cart')) { @mkdir(JPATH_SITE . DS . 'images' . DS . 'quick2cart'); } // $upload_path = $upload_path_folder.$original_file_name; // $image_upload_path_for_db. = $original_file_name; // Upload original img // Determine if resizing is needed for images // $adzone_media_dimnesions = $media->get_adzone_media_dimensions($adzone); foreach ($img_dimensions_config as $config) { $media_dimnesions = new stdClass(); $media_dimnesions->img_width = $params->get($config . '_width'); $media_dimnesions->img_height = $params->get($config . '_height'); $max_zone_width = $media_dimnesions->img_width; $max_zone_height = $media_dimnesions->img_height; switch ($config) { case 'small': $file_name_without_extension = $original_file_name_without_extension . "_S"; break; case 'medium': $file_name_without_extension = $original_file_name_without_extension . "_M"; break; case 'large': $file_name_without_extension = $original_file_name_without_extension . "_L"; break; default: $file_name_without_extension = $original_file_name_without_extension; break; } // If ($media_type_group['media_type_group']!="video" )// skip resizing for video if ($media_type_group['media_type_group'] == "image") { // Get uploaded image dimensions $media_size_info = $media->check_media_resizing_needed($media_dimnesions, $file_tmp_name); $resizing = 0; if ($media_size_info['resize']) { $resizing = 1; } switch ($resizing) { case 0: $new_media_width = $media_size_info['width_img']; $new_media_height = $media_size_info['height_img']; // @TODO not sure abt this $top_offset = 0; // @TODO not sure abt this $blank_height = $new_media_height; break; case 1: $new_dimensions = $media->get_new_dimensions($max_zone_width, $max_zone_height, 'auto'); $new_media_width = $new_dimensions['new_calculated_width']; $new_media_height = $new_dimensions['new_calculated_height']; $top_offset = $new_dimensions['top_offset']; $blank_height = $new_dimensions['blank_height']; break; } } else { // As we skipped resizing for video , we will use zone dimensions $new_media_width = $media_dimnesions->img_width; $new_media_height = $media_dimnesions->img_height; // @TODO not sure abt this $top_offset = 0; $blank_height = $new_media_height; } $colorR = 255; $colorG = 255; $colorB = 255; $upload_image = $media->uploadImage($file_field, $max_zone_width, $max_zone_height, $fullPath, $relPath, $colorR, $colorG, $colorB, $new_media_width, $new_media_height, $blank_height, $top_offset, $media_extension, $file_name_without_extension); } if ($upload_orig == '1') { $upload_path = $fullPath . $original_file_name; if (!JFile::upload($file_tmp_name, $upload_path)) { echo JText::_('COM_QUICK2CART_ERROR_MOVING_FILE'); return false; } } return $original_file_name; } } return false; }
function deletImg($imgarray) { $productHelper = new productHelper(); require_once JPATH_SITE . DS . 'components/com_quick2cart/helpers/media.php'; $media = new qtc_mediaHelper(); if (!empty($imgarray)) { foreach ($imgarray as $img) { $file_name_without_extension = $media->get_media_file_name_without_extension($img); $media_extension = $media->get_media_extension($img); $imgpath_withoutExtention = JPATH_SITE . DS . 'images/quick2cart' . DS . $file_name_without_extension; // DELETE ORIGINAL IMG $imgfilepath = JPATH_SITE . DS . 'images/quick2cart' . DS . $img; $productHelper->deleteFile($imgfilepath); // DELETE SMALL, M ,L IMAGES $imgfilepath = $imgpath_withoutExtention . '_S.' . $media_extension; $productHelper->deleteFile($imgfilepath); $imgfilepath = $imgpath_withoutExtention . '_M.' . $media_extension; $productHelper->deleteFile($imgfilepath); $imgfilepath = $imgpath_withoutExtention . '_L.' . $media_extension; $productHelper->deleteFile($imgfilepath); } } }