0 Пользователей и 1 Гость просматривают эту тему.
  • 13 Ответов
  • 6673 Просмотров
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Добрый день.
Подскажите как убрать автоматическое переименование загружаемых картинок товара.Надо что бы имя файла изображения оставалось изначальным, а к мини эскизу добавлялся префикс. Например загружаем фото с названием foto.jpg основная картинка остаётся foto.jpg а мини эскиз допустим foto_mini.jpg
Virtuemart 1.1.4
Подскажите.
Спасибо.
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #1 : 25.04.2010, 12:37:37 »
Нашёл вот такой вариант, но не понятно как правильно сделать.
1. в строке 228 написал:
      
   

Код
$to_file = $orig_file;//uniqid( $filename.'_' );
   
      


2. закаментировал с 230 по 237:
      
Код
	
/* Check image file format */
      /*if( $orig_file != "none" ) {
         $to_file .= $ext = '.'.Img2Thumb::GetImgType( $temp_file );
         if( !$to_file ) {
            $vmLogger->err( $image_type.' file is invalid: '.$file_type.'.' );
            return false;
         }
      }*/

Но думаю с этого можно начать)
*

Morello

  • Осваиваюсь на форуме
  • 49
  • 6 / 0
Re: Убрать переименование картинок.
« Ответ #2 : 26.04.2010, 14:49:13 »
Я как то исследовал модули на наличие таких преобразований. Так вот в 7ми или 8ми местах они. Исправил все - перестал работать сайт :)
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #3 : 26.04.2010, 14:55:35 »
Жаль,но надо сделать, всё же я думаю хороший хак будет
*

madcap

  • Осваиваюсь на форуме
  • 22
  • 4 / 0
Re: Убрать переименование картинок.
« Ответ #4 : 29.04.2010, 14:00:22 »
Нашёл вот такой вариант, но не понятно как правильно сделать.
1. в строке 228 написал:
Это в каком файле правится?
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #5 : 29.04.2010, 14:12:24 »
в файле imageTools.class.php
*

Morello

  • Осваиваюсь на форуме
  • 49
  • 6 / 0
Re: Убрать переименование картинок.
« Ответ #6 : 29.04.2010, 18:53:36 »
в файле imageTools.class.php

А чуток по конкретнее можно? И хотелось бы уточнить - опосля изменений работа стабильная? Заранее благодарю...
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #7 : 29.04.2010, 18:56:33 »
Это не рабочий вариант. Там же написано что с этого можно начать работу.
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #8 : 01.05.2010, 12:59:23 »
Ниже приведу текст файла imageTools.class.php всё же думаю что это в нём надо править. Кто знает подскажите что надо закомментировать что бы имена картинок оставались как есть?
Код
<?php
if( !defined( '_VALID_MOS' ) && !defined( '_JEXEC' ) ) die( 'Direct Access to '.basename(__FILE__).' is not allowed.' );
/**
* This file contains functions and classes for common image manipulation tasks
*
* @version $Id: imageTools.class.php 1852 2009-07-14 19:15:59Z soeren_nb $
* @package VirtueMart
* @subpackage classes
* @copyright Copyright (C) 2004-2008 soeren - All rights reserved.
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.php
* VirtueMart is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See /administrator/components/com_virtuemart/COPYRIGHT.php for copyright notices and details.
*
* http://virtuemart.net
*/

class vmImageTools {
/**
* Validates an uploaded image. Creates UNIX commands to be used
* by the process_images function, which has to be called after
* the validation.
* @author jep
* @author soeren
* @static
* @param array $d
* @param string $field_name The name of the field in the table $table, the image is assigned to [e.g. product_thumb_image]
* @param string $table_name The name of a table in the database [e.g. #__{vm}_product]
* @return boolean When the upload validation was sucessfull, true is returned, otherwise false
*/
function validate_image(&$d,$field_name,$table_name) {
global $vmLogger;

// The commands to be executed by the process_images
    // function are returned as strings in an array here.
    if (empty($d['image_commands']) || !empty( $_REQUEST['image_commands'])) {
    unset( $_REQUEST['image_commands'] );
        $d['image_commands'] = array();
    }
// Generate the path to images
$path  = IMAGEPATH;
$path .= $table_name . "/";

// Check permissions to write to destination directory
// Workaround for Window$
if(strstr($path , ":" )) {
$path_begin = substr( $path, strpos( $path , ":" )+1, strlen($path));
$path = str_replace( "//", "/", $path_begin );
}
if (!is_dir( $path )) {
mkdir( $path, 0777 );
$vmLogger->debug( 'Had to create the directory '.$path);
}

if( !is_writable($path) && !empty( $_FILES[$field_name]["tmp_name"]) ) {
$vmLogger->err( 'Cannot write to '.$table_name.' image directory: '.$path );
return false;
}
// Check for upload errors
require_once( CLASSPATH. 'ps_product_files.php');
ps_product_files::checkUploadedFile( $field_name );

// proof of concept fix by jmarsik 20090422 - safely move the uploaded file from upload_tmp_dir to temporary location (hopefully) included in open_basedir, following code will be much happier :)
// if the file is not moved, following code will try to manipulate it using functions that check open_basedir (for example copy, file_exists, unlink, getimagesize)
if( !empty ( $_FILES[$field_name]["tmp_name"] ) && is_uploaded_file($_FILES[$field_name]["tmp_name"]) )
{
$tmpfile_moved_from_uploaded_file = $path . "tmpForThumb_" . basename($_FILES[$field_name]["tmp_name"]);
$vmLogger->debug("Moving file from " . $_FILES[$field_name]["tmp_name"] . " to " . $tmpfile_moved_from_uploaded_file . " (helps when upload_tmp_dir is not in open_basedir)");
move_uploaded_file($_FILES[$field_name]["tmp_name"], $tmpfile_moved_from_uploaded_file);
$_FILES[$field_name]["tmp_name"] = $tmpfile_moved_from_uploaded_file;
}

$tmp_field_name = str_replace( "thumb", "full", $field_name );
// Class for resizing Thumbnails
require_once( CLASSPATH . "class.img2thumb.php");

if( @$d[$tmp_field_name.'_action'] == 'auto_resize' ) {

// proof of concept fix by jmarsik 20090422 - safely move the uploaded file from upload_tmp_dir to temporary location (hopefully) included in open_basedir, following code will be much happier :)
// if the file is not moved, following code will try to manipulate it using functions that check open_basedir (for example copy, file_exists, unlink, getimagesize)
if( !empty ( $_FILES[$tmp_field_name]["tmp_name"] ) && is_uploaded_file($_FILES[$tmp_field_name]["tmp_name"]) )
{
$tmpfile_moved_from_uploaded_file = $path . "tmpForThumb_" . basename($_FILES[$tmp_field_name]["tmp_name"]);
$vmLogger->debug("Moving file from " . $_FILES[$tmp_field_name]["tmp_name"] . " to " . $tmpfile_moved_from_uploaded_file . " (helps when upload_tmp_dir is not in open_basedir)");
move_uploaded_file($_FILES[$tmp_field_name]["tmp_name"], $tmpfile_moved_from_uploaded_file);
$_FILES[$tmp_field_name]["tmp_name"] = $tmpfile_moved_from_uploaded_file;
}

// Resize the Full Image
if( !empty ( $_FILES[$tmp_field_name]["tmp_name"] )) {
$full_file = $_FILES[$tmp_field_name]["tmp_name"];
$image_info = getimagesize($full_file);
}
elseif( !empty($d[$tmp_field_name."_url"] )) {
$tmp_file_from_url = $full_file = ps_product_files::getRemoteFile($d[$tmp_field_name."_url"]);
if( $full_file ) {
$vmLogger->debug( 'Successfully fetched the image file from '.$d[$tmp_field_name."_url"].' for later resizing' );
$image_info = getimagesize($full_file);
}
}
if( !empty( $image_info )) {

if( $image_info[2] == 1) {
if( function_exists("imagegif") ) {
$ext = ".gif";
$noimgif="";
}
else {
$ext = ".jpg";
$noimgif = ".gif";
}
}
elseif( $image_info[2] == 2) {
$ext = ".jpg";
$noimgif="";
}
elseif( $image_info[2] == 3) {
$ext = ".png";
$noimgif="";
}
$vmLogger->debug( 'The resized Thumbnail will have extension '.$noimgif.$ext );
/* Generate Image Destination File Name */
if( !empty( $d[$table_name.'_name'] )) {
$filename = substr( $d[$table_name.'_name'], 0, 16 );
$filename = vmSafeFileName( $filename );
}
else {
$filename = md5( 'virtuemart' );
}
$to_file_thumb = uniqid( $filename.'_' );

$fileout = IMAGEPATH."$table_name/resized/$to_file_thumb".'_'.PSHOP_IMG_WIDTH.'x'.PSHOP_IMG_HEIGHT.$noimgif.$ext;

if( !file_exists( dirname( $fileout ))) {
mkdir( dirname( $fileout ));
$vmLogger->debug('Created Directory '.dirname( $fileout ));
}
$neu = new Img2Thumb( $full_file, PSHOP_IMG_WIDTH, PSHOP_IMG_HEIGHT, $fileout, 0, 255, 255, 255 );
$thumbname = 'resized/'.basename( $fileout );
$vmLogger->debug( 'Finished creating the thumbnail '.$thumbname );

if( isset($tmp_file_from_url) ) unlink( realpath($tmp_file_from_url) );
$tmp_field_name = str_replace( "full", "thumb", $tmp_field_name );
$tmp_field_name = str_replace( "_url", "", $tmp_field_name );
$_FILES[$tmp_field_name]['tmp_name'] = $fileout;
$_FILES[$tmp_field_name]['name'] = $thumbname;
$d[$tmp_field_name] = $thumbname;

$curr_file = isset($_REQUEST[$tmp_field_name."_curr"])? $_REQUEST[$tmp_field_name."_curr"] : "";

if (!empty($curr_file)) {

            $delete = str_replace("\\", "/", realpath($path."/".$curr_file));
            $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $delete
        );

$vmLogger->debug( 'Preparing: delete old thumbnail image: '.$delete );
/* Remove the resized image if exists */
if( PSHOP_IMG_RESIZE_ENABLE=="1" ) {
$pathinfo = pathinfo( $delete );
isset($pathinfo["dirname"]) or $pathinfo["dirname"] = "";
isset($pathinfo["extension"]) or $pathinfo["extension"] = "";
$filehash = basename( $delete, ".".$pathinfo["extension"] );
$resizedfilename = $pathinfo["dirname"]."/resized/".$filehash."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.".".$pathinfo["extension"];

                $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $resizedfilename
        );
$vmLogger->debug( 'Preparing: delete resized thumbnail '.$resizedfilename );

}
}
}
}

$temp_file = isset($_FILES[$field_name]['tmp_name'])? $_FILES[$field_name]['tmp_name'] : "";
$file_type = isset($_FILES[$field_name]['type'])? $_FILES[$field_name]['type'] : "";

$orig_file = isset($_FILES[$field_name]["name"])? $_FILES[$field_name]['name'] : "";
$curr_file = isset($_REQUEST[$field_name."_curr"])? $_REQUEST[$field_name."_curr"] : "";

/* Generate text to display in error messages */
if (eregi("thumb",$field_name)) {
$image_type = "thumbnail image";
} elseif (eregi("full",$field_name))  {
$image_type = "full image";
} else {
$image_type = ereg_replace("_"," ",$field_name);
}

/* If User types "none" in Image Upload Field */
if ( @$d[$field_name."_action"] == "delete") {
/* If there is a current image file */
if (!empty($curr_file)) {

            $delete = str_replace("\\", "/", realpath($path."/".$curr_file));
            $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $delete
        );

$vmLogger->debug( 'Preparing: delete old '.$image_type.' '.$delete );
/* Remove the resized image if exists */
if( PSHOP_IMG_RESIZE_ENABLE=="1" && $image_type == "thumbnail image") {
$pathinfo = pathinfo( $delete );
isset($pathinfo["dirname"]) or $pathinfo["dirname"] = "";
isset($pathinfo["extension"]) or $pathinfo["extension"] = "";
$filehash = basename( $delete, ".".$pathinfo["extension"] );
$resizedfilename = $pathinfo["dirname"]."/resized/".$filehash."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.".".$pathinfo["extension"];

                $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $resizedfilename
        );
$vmLogger->debug( 'Preparing: delete resized thumbnail '.$resizedfilename );

}
}
$d[$field_name] = "";
return true;
}
/* If upload fails */
elseif($orig_file and $temp_file == "none") {
$vmLogger->err( $image_type.' upload failed.');
return false;
}

else {
// If nothing was entered in the Upload box, there is no image to process
if (!$orig_file )  {
$d[$field_name] = $curr_file;
return true;
}
}
if( empty( $temp_file )) {
$vmLogger->err( 'The File Upload was not successful: there\'s no uploaded temporary file!' );
return false;
}

/* Generate Image Destination File Name */
if( !empty( $d[$table_name.'_name'] )) {
$filename = substr( $d[$table_name.'_name'], 0, 16 );
$filename = vmSafeFileName( $filename );
}
else {
$filename = md5( 'virtuemart' );
}
$to_file = uniqid( $filename.'_' );

/* Check image file format */
if( $orig_file != "none" ) {
$to_file .= $ext = '.'.Img2Thumb::GetImgType( $temp_file );
if( !$to_file ) {
$vmLogger->err( $image_type.' file is invalid: '.$file_type.'.' );
return false;
}
}
/*
** If it gets to this point then there is an uploaded file in the system
** and it is a valid image file.
*/


/* If Updating */
if (!empty($curr_file)) {
/* Command to remove old image file */
$delete = str_replace( "\\", "/", realpath($path)."/".$curr_file);

        $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $delete
        );

/* Remove the resized image if exists */
if( PSHOP_IMG_RESIZE_ENABLE=="1" && $image_type == "thumbnail image") {
$pathinfo = pathinfo( $delete );
$filehash = basename( $delete, ".".$pathinfo["extension"] );
$resizedfilename = $pathinfo["dirname"]."/resized/".$filehash."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.".".$pathinfo["extension"];

            $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $resizedfilename
        );
$vmLogger->debug( 'Preparing: delete resized thumbnail '.$resizedfilename );

}
}

/* Command to move uploaded file into destination directory */
    // Command to move uploaded file into destination directory
    $d["image_commands"][] = array( 'command' => 'move_uploaded_file',
        'param1' => $temp_file,
        'param2' => $path.$to_file
        );
    $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $temp_file
        );

if( empty( $d[$field_name] )) {
/* Return new image file name */
$d[$field_name] = $to_file;
}

return true;
}

/**
* The function that safely executes $d['image_commands'] and catches errors
*
* @param array $d
* @return boolean True when all image commands were executed successfully, false when not
*/
function process_images(&$d) {
global $vmLogger;
require_once(CLASSPATH.'ps_product_files.php');
       
    if (!empty($d["image_commands"])) {

        foreach( $d['image_commands'] as $exec ) {
        switch( $exec['command'] ) {
        case 'unlink':
        if( file_exists( $exec['param1']) ) {
        $ret = unlink( $exec['param1'] );
        } else {
        $ret = true;
        }
        break;
        case 'move_uploaded_file':
        if( is_uploaded_file( $exec['param1']) ) {
        $ret = move_uploaded_file( $exec['param1'], $exec['param2'] );
        } else {
        $ret = copy( $exec['param1'], $exec['param2'] );
        }
@chmod( $exec['param2'], 0666 );
        break;
        }

            if ($ret == false) {
                $vmLogger->err ( 'The following image update command failed: '. $exec['command'] );
                return false;
            }
            else {
                $vmLogger->debug( 'Successfully processed image command: '.$exec['command'] );
            }

        }
        $d["image_commands"] = array();
    }
    return true;
}
/**
* Resizes an image to a given size
*
* @since VirtueMart 1.1.0
* @author soeren
*
* @static

* @param string $sourceFile
* @param string $resizedFile
* @param int $width
* @param int $height
* @param boolean $enlargeSmallerImg
* @return boolean
*/
function resizeImage($sourceFile, $resizedFile, $height, $width, $enlargeSmallerImg=false ) {
global $vmLogger;
if( $width <= 0 || $height <= 0 ) {
if( is_callable(array($vmLogger,'err'))) {
$vmLogger->err( 'An invalid image height or weight was specified!');
return false;
}
}
// We must take care of images which are already smaller than the size they are to be resized to
// In most case it is not wanted to enlarge them
$imgArr = @getimagesize( $sourceFile );
$isSmallerThanResizeto = $imgArr[0] < $width && $imgArr[1] < $height;
if( $isSmallerThanResizeto && !$enlargeSmallerImg ) {
if( $sourceFile != $resizedFile ) {
@copy( $sourceFile, $resizedFile );
}
$vmLogger->debug( 'The image '.basename( $sourceFile ).' was not resized because would have been enlarged.');
return false;
}

// Class for resizing Thumbnails
require_once( CLASSPATH . "class.img2thumb.php");
$Img2Thumb = new Img2Thumb( $sourceFile, $width, $height, $resizedFile, 0, 255, 255, 255 );
if( is_file( $resizedFile )) {
return true;
}
else {
return false;
}
}
/**
* Returns the filename of an image's resized copy in the /resized folder
* @since VirtueMart 1.1.0
* @author soeren
* @static
* @param string $filename
* @param string $section
* @param string $ext
* @return string
*/
function getResizedFilename( $filename, $section='product', $ext='', $height=0, $width=0 ) {
$fileinfo = pathinfo( $filename );
if( $ext == '' ) {
$ext = $fileinfo['extension'];
}

$width = ( $width > 0 )? (int)$width : PSHOP_IMG_WIDTH;
$height = ( $height > 0 )? (int)$height : PSHOP_IMG_HEIGHT;

$basename = str_replace( "_".$height."x".$width, '', basename( $filename, '.'.$ext ) );
return IMAGEPATH.$section.'/resized/'.$basename."_".$height."x".$width.'.'.$ext;

}
}
*

newjey

  • Захожу иногда
  • 405
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #9 : 04.05.2010, 20:16:09 »
Нашёл решение под VirtueMart 1.0.10
Изминения проделываются в файле administrator>components>com_virtuemart>classes>ps_main.php
Найти
Код
/* Generate Image Destination File Name */
$to_file_thumb = md5(uniqid("VirtueMart"));
$fileout = IMAGEPATH."/product/resized/".$to_file_thumb."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.$noimgif.$ext;
$neu = new Img2Thumb( $full_file, PSHOP_IMG_WIDTH, PSHOP_IMG_HEIGHT, $fileout, 0, 255, 255, 255 );
$vmLogger->debug( 'Finished creating the thumbnail' );

if( isset($tmp_file_from_url) ) unlink( realpath($tmp_file_from_url) );
$tmp_field_name = str_replace( "full", "thumb", $tmp_field_name );
$tmp_field_name = str_replace( "_url", "", $tmp_field_name );
$_FILES[$tmp_field_name]['tmp_name'] = $fileout;
$_FILES[$tmp_field_name]['name'] = basename($fileout);
$d[$tmp_field_name] = basename($fileout);

$d['resizing_prepared'] = "1";
}
}

$temp_file = isset($_FILES[$field_name]['tmp_name'])? $_FILES[$field_name]['tmp_name'] : "";
$file_type = isset($_FILES[$field_name]['type'])? $_FILES[$field_name]['type'] : "";

$orig_file = isset($_FILES[$field_name]["name"])? $_FILES[$field_name]['name'] : "";
$curr_file = isset($_REQUEST[$field_name."_curr"])? $_REQUEST[$field_name."_curr"] : "";

заменить на
Код
		/* Generate Image Destination File Name */
$orig_filename = $_FILES[$tmp_field_name]['name'];
$orig_filename = substr($orig_filename,0,strrpos($orig_filename,'.'));

$to_thumb = $orig_filename;
$thumbout = IMAGEPATH."product/resized/".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT."_".$to_thumb.$noimgif.$ext;
$thumb = new Img2Thumb( $full_file, PSHOP_IMG_WIDTH, PSHOP_IMG_HEIGHT, $thumbout, 0, 255, 255, 255 );
$vmLogger->debug( 'Finished creating the thumbnail '. $thumbout);

if( isset($tmp_file_from_url) ) unlink( realpath($tmp_file_from_url) );
$tmp_field_name = str_replace( "full", "thumb", $tmp_field_name );
$tmp_field_name = str_replace( "_url", "", $tmp_field_name );
$_FILES[$tmp_field_name]['tmp_name'] = $thumbout;
$_FILES[$tmp_field_name]['name'] = basename($thumbout);
$d[$tmp_field_name] = basename($thumbout);

$d['resizing_prepared'] = "1";
}
}

$temp_file = isset($_FILES[$field_name]['tmp_name'])? $_FILES[$field_name]['tmp_name'] : "";
$file_type = isset($_FILES[$field_name]['type'])? $_FILES[$field_name]['type'] : "";

$orig_file = isset($_FILES[$field_name]["name"])? $_FILES[$field_name]['name'] : "";
$curr_file = isset($_REQUEST[$field_name."_curr"])? $_REQUEST[$field_name."_curr"] : "";
$orig_filename = substr($orig_file,0,strrpos($orig_file,'.'));

далее этот код
Код
// Generate Image Destination File Name
$to_file = md5(uniqid("VirtueMart"));
заменить на этот
Код
	// Generate Image Destination File Name
if($image_type == "thumbnail image") {
$to_file="thumb_".$orig_filename;
} else {
$to_file=$orig_filename;
}

Кто-то может подсказать как переделать данный хак для версии 1.1.4

какие надо произвести изменения в коде
Код
/* Generate Image Destination File Name */
if( !empty( $d[$table_name.'_name'] )) {
$filename = substr( $d[$table_name.'_name'], 0, 16 );
$filename = vmSafeFileName( $filename );
}
else {
$filename = md5( 'virtuemart' );
}
$to_file_thumb = uniqid( $filename.'_' );

$fileout = IMAGEPATH."$table_name/resized/$to_file_thumb".'_'.PSHOP_IMG_WIDTH.'x'.PSHOP_IMG_HEIGHT.$noimgif.$ext;

if( !file_exists( dirname( $fileout ))) {
mkdir( dirname( $fileout ));
$vmLogger->debug('Created Directory '.dirname( $fileout ));
}
$neu = new Img2Thumb( $full_file, PSHOP_IMG_WIDTH, PSHOP_IMG_HEIGHT, $fileout, 0, 255, 255, 255 );
$thumbname = 'resized/'.basename( $fileout );
$vmLogger->debug( 'Finished creating the thumbnail '.$thumbname );

if( isset($tmp_file_from_url) ) unlink( realpath($tmp_file_from_url) );
$tmp_field_name = str_replace( "full", "thumb", $tmp_field_name );
$tmp_field_name = str_replace( "_url", "", $tmp_field_name );
$_FILES[$tmp_field_name]['tmp_name'] = $fileout;
$_FILES[$tmp_field_name]['name'] = $thumbname;
$d[$tmp_field_name] = $thumbname;

$curr_file = isset($_REQUEST[$tmp_field_name."_curr"])? $_REQUEST[$tmp_field_name."_curr"] : "";

if (!empty($curr_file)) {

            $delete = str_replace("\\", "/", realpath($path."/".$curr_file));
            $d["image_commands"][] = array( 'command' => 'unlink',
        'param1' => $delete
        );

$vmLogger->debug( 'Preparing: delete old thumbnail image: '.$delete );
Спасибо.
*

Marv

  • Осваиваюсь на форуме
  • 26
  • 2 / 0
Re: Убрать переименование картинок.
« Ответ #10 : 13.08.2010, 12:42:18 »
Парился сегодня по этому же поводу, но чтобы не сильно воевать с виртуемартом и не править исходный код компонента, остановился на таком варианте:

- Если картинка имеет уникальное имя, то она не переименовывается.
- Отлично, тогда называем картинки: большую - с1_любой-набор-текста.jpg, маленькую - с1_small_тот-же-набор-текста.jpg. Например: с1_b225.jpg и с1_small_b225.jpg.
- А потом уже в скрипте (у меня это JavaScript, который показывает большую картинку по щелчку на маленькой) разбираем имя файла как-нибудь так:

Код
clrSrc = color.src.slice(0, color.src.lastIndexOf('_small')) + color.src.slice(color.src.lastIndexOf('_small')+6,color.src.length);	

Ну, или прикручиваем регулярное выражение. В них я не силен.

В итоге из имени маленькой картинки получаем имя большой картинки, которая ей соответствует. Или наоборот. Не знаю насколько вам подойдет такое решение, но пролистав 30 страниц яндекса понял, что оно во много раз проще, чем править код компонента.
*

Marilyn Manson

  • Осваиваюсь на форуме
  • 36
  • 0 / 0
Re: Убрать переименование картинок.
« Ответ #11 : 04.04.2011, 00:31:39 »
Тоже интересует этот вопрос! Очень прошу помочь в удалении переименования картинок
*

magmag

  • Осваиваюсь на форуме
  • 38
  • 2 / 0
*

sanekk

  • Захожу иногда
  • 66
  • 0 / 0
Re: Убрать переименование картинок.
« Ответ #13 : 28.05.2012, 17:11:38 »
Здесь есть решение:
http://itgik.blogspot.com/2011/06/virtuemart.html?showComment=1328709366186#c203308448582829618

и http://beagler.ru/virtuemart/27-krasivye-imena-fajlov-dlya-foto-tovarov.html

Ни чего не работает. единственное только, что можно сделать, так это заменить в файле imageTools.class.php

$filename = substr( $d[$table_name.'_name'], 0, 16 );

на

$filename = basename($_FILES['product_full_image']['name'], 0);

и заменить

$to_file = uniqid( $filename.'_' );

на

$to_file = $filename;

Теперь загружаемые файлы буду иметь имя файла. Латиница так и не работает. в Результате будет к примеру MAS.jpg.jpg Это лучше чем: ____________MAS_4f43f078f2c12.jpg
Теперь картинки сохраняются с именем файла но на конце остается два расширения MAS.jpg.jpg. Если кто знает как подскажите пожалуйста.

Чтобы оставить сообщение,
Вам необходимо Войти или Зарегистрироваться
 

как убрать из ссылки component/virtuemart/

Автор kpk17

Ответов: 11
Просмотров: 12345
Последний ответ 10.03.2015, 14:29:19
от Kiparus
Не могу убрать форму "Задайте вопрос..." на странице товара

Автор abrodski

Ответов: 1
Просмотров: 1387
Последний ответ 20.05.2014, 14:30:44
от abrodski
Убрать слово "Просмотр" на главной странице

Автор bakyt

Ответов: 2
Просмотров: 1094
Последний ответ 10.06.2013, 10:57:58
от draff
Убрать слово "категории" с страницы сайта

Автор Dima0785

Ответов: 20
Просмотров: 8652
Последний ответ 04.04.2013, 10:40:02
от Proka
Убрать шаг подтверждения заказа при его оформлении

Автор ibrogim

Ответов: 7
Просмотров: 6861
Последний ответ 27.10.2012, 16:31:35
от fobos-net