News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Images not showing on front end

Started by marty78, January 29, 2008, 23:47:43 PM

Previous topic - Next topic

Crusty

found the code that produces the thumnails, from what i can gather it goes looking for the created date. The problem i have is that i'm +15hours time difference from my server. is there a way the code can be changed or flagged so that it will auto update from new pictures? or a manual create thumnail from the backend by a button to auto update thumnails?

tell me if i'm waay off target here.

this is the code i found in ps_product_files.php
it starts at line 128


function add( &$d ) {
global $mosConfig_absolute_path, $mosConfig_live_site,
$database, $VM_LANG, $vmLogger;

$db = new ps_DB;
$timestamp = time();

if (!$this->validate_add($d)) {
return False;
}

if( empty( $d["file_published"] )) {
$d["file_published"] = 0;
}
if( empty( $d["file_create_thumbnail"] )) {
$d["file_create_thumbnail"] = 0;
}

// Do we have an uploaded file?
if( !empty($_FILES['file_upload']['name']) ) {
// Uploaded file branch
$upload_success = false;
$fileinfo = pathinfo( $_FILES['file_upload']['name'] );
$ext = $fileinfo["extension"];

if( $this->fileexists ) {
// must rename uploaded file!
$filename = uniqid("ren_") . $_FILES['file_upload']['name'];
}
else {
$filename = $_FILES['file_upload']['name'];
}

// file_title...Beware of renaming files!
if( @$d["file_title"] == $_FILES['file_upload']['name'] ) {
if( $filename != $_FILES['file_upload']['name'] ) {
$d["file_title"] = $filename;
}
}

switch( $d["upload_dir"] ) {
case "IMAGEPATH":
$uploaddir = IMAGEPATH ."product/";
break;
case "FILEPATH":
$uploaddir = trim( $d["file_path"] );
if( !file_exists($uploaddir) ) {
@mkdir( $uploaddir );
}
if( !file_exists( $uploaddir ) ) {
$vmLogger->err( $VM_LANG->_PHPSHOP_FILES_PATH_ERROR );
return false;
}

if( substr( $uploaddir, strlen($uploaddir)-1, 1) != '/') {
$uploaddir .= '/';
}
break;
case "DOWNLOADPATH":
$uploaddir = DOWNLOADROOT;
break;
}
if( $this->checkUploadedFile( 'file_upload' ) ) {
$upload_success = $this->moveUploadedFile( 'file_upload', $uploaddir.$filename);
}
else {
$vmLogger->err( $VM_LANG->_PHPSHOP_FILES_UPLOAD_FAILURE );
return false;
}

if( @$d['file_type'] == "image" ) {
$is_image = "1";
$d["file_url"] = IMAGEURL."product/".$filename;

$file_contents = "";

if( $d["file_create_thumbnail"] == "1" ) {
## RESIZE THE IMAGE ####
require_once( CLASSPATH . "class.img2thumb.php" );
$fileout = $uploaddir . "resized/".basename($filename, ".".$ext)."_".PSHOP_IMG_WIDTH."x".PSHOP_IMG_HEIGHT.".$ext";
$tmp_filename = $uploaddir . $filename;
$newxsize = PSHOP_IMG_WIDTH;
$newysize = PSHOP_IMG_HEIGHT;
$maxsize = 0;

$bgred = $bggreen = $bgblue = 255;
/* We need to resize the image and Save the new one (all done in the constructor) */
$neu = new Img2Thumb($tmp_filename,$newxsize,$newysize,$fileout,$maxsize,$bgred,$bggreen,$bgblue);

if( is_file( $fileout ) ) {
$vmLogger->info( $VM_LANG->_PHPSHOP_FILES_IMAGE_RESIZE_SUCCESS );
$thumbimg = getimagesize( $fileout );
$file_image_thumb_width = $thumbimg[0];
$file_image_thumb_height = $thumbimg[1];
}
else {
$vmLogger->warning( $VM_LANG->_PHPSHOP_FILES_IMAGE_RESIZE_FAILURE );
$file_image_thumb_height = "";
$file_image_thumb_width = "";
}
$fullimg = getimagesize( $tmp_filename );
$file_image_width = $fullimg[0];
$file_image_height = $fullimg[1];
$filename = $tmp_filename;
}

}
else {
### File (no image) Upload ###
$is_image = "0";
$filename = $uploaddir . $filename;
$file_image_height = $file_image_width = $file_image_thumb_height = $file_image_thumb_width = "";
}
}
else {
if( $d['file_type'] == "image" ) {
$is_image = "1";
}
else {
$is_image = "0";
}
$filename = "";
$file_contents = "";
$ext = "";
$upload_success = true;
$file_image_height = $file_image_width = $file_image_thumb_height = $file_image_thumb_width = "";
}

$filename = $GLOBALS['vmInputFilter']->safeSQL( $filename );
$d["file_title"] = $GLOBALS['vmInputFilter']->safeSQL( $d["file_title"] );

$q = "INSERT INTO #__{vm}_product_files ";
$q .= "(file_product_id, file_name, file_title, file_extension, file_mimetype, file_url, file_published,";
$q .= "file_is_image, file_image_height , file_image_width , file_image_thumb_height, file_image_thumb_width )";
$q .= " VALUES ('".$d["product_id"]."', '$filename','".$d["file_title"] . "','$ext','".$_FILES['file_upload']['type']."', '".$d['file_url']."', '".$d["file_published"]."',";
$q .= "'$is_image', '$file_image_height', '$file_image_width', '$file_image_thumb_height', '$file_image_thumb_width')";
$db->setQuery($q);
$db->query();

return True;

}

elixa

#16
This is the same problem that i am having. All worked fine until I changed the details in a category then the thumb of the product doesn't show even though it seems to be there. If you click on it the larger image opens.  All permissions OK. Several themes tested. Error reproduced a couple of times now (arrrrg)
Do you any of you clever coders know what this might be?

Well, I just found one way out  -I hope - Upgrade joomla to 1.5.2 and vm to 1.1.0